NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL Syntax questions

Susan Shemin susan_shemin at yahoo.com
Wed May 28 19:02:02 EDT 2008


For #1, if you had parentheses around what you want together, MySQL will understand what to return.  For example (no logic here, just example):
SELECT * FROM table WHERE ( this=this ) AND ( ( that=that OR 
thing=thing ) OR ( ( blah=blah OR foo=foo ) AND ( bar=bar OR etc=etc ) ) )


----- Original Message ----
From: Kristina Anderson <ka at kacomputerconsulting.com>
To: talk at lists.nyphp.org
Sent: Wednesday, May 28, 2008 3:42:44 PM
Subject: [nycphp-talk] MySQL Syntax questions

I have two questions regarding syntax for MySQL queries.

1.  I have complex queries where there are lots of conditional 
statements, i.e. SELECT * FROM table WHERE this=this AND that=that OR 
thing=thing OR blah=blah OR foo=foo AND bar=bar OR etc=etc OR 
thing2=thing2...


They are not erroring out but they aren't narrowing the resultset 
sufficiently...do I need parentheses or is there something else I need?

2.  How can I select the last row inserted from a table WHERE 
field1=somethingineed and field2 is NULL?

Thanks in advance...full of questions today I am!



--- Kristina 
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080528/bd8fd67f/attachment.html>


More information about the talk mailing list