Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Getting everything but empty fields in MySql query

LEGEND ,
Jul 23, 2008 Jul 23, 2008
I was trying to get all users email addresses that actually have a email
address entered in the database. I tried:

<cfquery name="AllUsersCSV" datasource="SalleBoise">
select #form.sql#
from inforeq
where #Search1#=<cfqueryparam cfsqltype="cf_sql_smallint" value="1"> <cfif
form.sql eq "Cust_Email">and Cust_Email not ''</cfif>
</cfquery>

But kept getting a "You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near '''' at line 3" error

What would be the 'proper' way to search for these records?


416
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 23, 2008 Jul 23, 2008
Your specific error comes from the word "not". It should be either <> ", is not null", or both, depending on how you store your data.

There may be some other issues, depending on what the values of form.sql and Search1 are.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 23, 2008 Jul 23, 2008
You can print your SQL statement and copy the statement and execute it in SQL. This way you can easily figure out the problem.

Hope the above helps.
Thanks,
Satheesh.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 23, 2008 Jul 23, 2008
Thanks Dan, the <> worked just great......

"Dan Bracuk" <webforumsuser@macromedia.com> wrote in message
news:g67ofl$j26$1@forums.macromedia.com...
> Your specific error comes from the word "not". It should be either <> ",
> is
> not null", or both, depending on how you store your data.
>
> There may be some other issues, depending on what the values of form.sql
> and
> Search1 are.
>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 23, 2008 Jul 23, 2008
LATEST
Steve Grosz wrote:
> Thanks Dan, the <> worked just great......

The on-line MySQL documentation can also be very helpful for syntax problems or questions
http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_not-equal
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources