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!

Using AND problem 1

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
I have a query having:

FROM Orders WHERE OrderNumber ='11111' && Group ='2' ORDER BY etc

I have tried &&, AND, & but it fails. Can someone tell me how to use a WHERE XXXX=YYY AND ZZZ=BBB

I also tried brackets arount statement/s, no avail. Thanks
 
Actually just after hitting the send thread button, wondered if its a bad idea anyway using a field named group? Bit near reserved word? Thanks
 
yes, GROUP is a reserved word

and the operator you should be using is AND, not those horrible mysql-proprietary ampersands

r937.com | rudy.ca
 
Many thanks r937. I changed the table field name, replaced the && with AND, it now works. Thanks, have a star.
 
Although it's a very good idea NOT to use reserved words as identifiers, you can if you wish, AS LONG AS they are surrounded by the identifier quote character, which is the backtick. You'll notice that all queries generated by MySQLAdmin automatically use them.
See
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Note though that the backtick is proprietary to mysql so it won't work in mssql or oracle for instance.
 
True, GD - but this is the MySQL forum....[smile]

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
It may be a mysql forum, but we've slid as far as PHP code, shell, MSSQL and other weird things over the last few years, so clarifying these points is always a benefit to those who may cross-platform from time to time :)





______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
True enough John, I just see so many editors that use backticks that people might think they are standard. they may be using mysql for this specific project, but have another platform at work that won't accept them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top