[thelist] database query question

rudy r937 at interlog.com
Sat May 25 16:47:00 CDT 2002


>     select zipcode, email url
>       from Main_tbl
>      where zipcode = zipcode
>
> Now if I take out the email, url and leave just the zipcode
> it works...  but I'm not sure why.

hi jeremy

that there should work even with email and url included

foo=foo for any valid column foo

i.e.  zipcode=zipcode is true for all rows

(except -- maybe -- if it's null, but that's a different problem)

you didn't say which language you're running your query in, so i get to
choose the language to give you my answer in, and i'll choose coldfusion

(you're probably using asp, because you have to go to the trouble of
assigning the value of your query to the SQL variable, heh)

so anyhow, you need to write the query using the value of your form field
variable --

         where zipcode = #form.zipcode#

or

         where zipcode = '#form.zipcode#'

depending on whether the zipcode column is character or numeric

(it'll be character if you allow for 9 digits *and* the hyphen)

always use single quotes for character strings in the query itself -- then
you can use double quotes to assign the query statement, if you have to


rudy
http://rudy.ca/




More information about the thelist mailing list