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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where question 1

Status
Not open for further replies.

jewel464g

Technical User
Jul 18, 2001
198
US
It's been quite some time since I've worked with SQL. This is what I need to do.

SELECT * FROM hotlines WHERE category=admin ORDER BY name

Select everything from the table hotlines with the field category contains the word admin, the order it by name. Something is obviously wrong with my syntax because I get errors when I put the WHERE part in. The following statment works fine. So it must be the WHERE part.

SELECT * FROM hotlines ORDER BY name


Thanks,
Jewel

When faced with a decision, always ask, 'Which would be the most fun?'
 
I believe it would look something like this:

SELECT * FROM hotlines WHERE category='%admin%' ORDER BY name

Hope this helps...

Chris Scott
The Whole Computer Medical Systems
 
Your query is not '...where the field "category" contains the word "admin"...'. Your query is '...where the field "category" is exactly the value of the field[/i] "admin"...'

If you're looking for a string value, put it in single quotes. Otherwise, you're comparing two fields. I'll bet you're getting a "column name does not exist" error.


Also, if you're looking for a field containing a string, you need to use something like the "like" operator:

SELECT * from hotlines where category like '%admin%' order by name

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top