Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying using single quotes

Status
Not open for further replies.

vbredpgr

Programmer
May 20, 2003
7
US
I'm used to running queries on Transact-SQL. I'm sure there's something wrong with the Where clause in the following statement:

Code:
select e_search from tbl_memory where show = 'Y'

I'm using this with PHP but I still get the error even when I'm running this in phpMyAdmin.

Here's my error:

#1064 - 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 'show = 'Y'

Thanks.
 
Should be :

Code:
SELECT e_search FROM tbl_memory WHERE show [b]LIKE[/b] 'Y'
 
I found the solution. When I use the tick symbol( ` ) around the fields and table names it worked:

Code:
SELECT `e_search` FROM `tbl_memory` WHERE `show` = 'Y'

Thanks for your input
 
The reason for that, is that Show is a reserved word in MYSQL. so you need the back ticks to differentiate it.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top