RE: [PHP-DB] Query problem
you can't use COL_NAME = NULL or COL_NAME = 'NULL' and get the desired results , you have to check for IS NULL/ IS NOT NULLSo, change the query to SELECT * FROM TABLE WHERE MY_FIELD IS NULL or, SELECT * FROM TABLE WHERE MY_FIELD IS NOT NULL >From my understanding when you check for COL_NAME = 'Null' you're actually checking to see if your field contains a _string_ 'Null' hth jeff "Boaz Yahav" <[EMAIL PROTECTED]To: "Ron Allen" <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> .net.il> cc: Subject: RE: [PHP-DB] Query problem 07/22/2003 03:16 PM Assuming you run MySQL, why don't you just remove the " ' "? SELECT * FROM MyTable WHERE MyField=NULL Sincerely berber Visit http://www.weberdev.com/ Today!!! To see where PHP might take you tomorrow. Share your code : http://addexample.weberdev.com -Original Message- From: Ron Allen [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 11:29 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Query problem I have done this in the past, but for some reason it isn't working now (maybe a moron). I am trying to select all of the empty or NULL fields in a column. This is what I have select * from ticket where Type = 'Line' and Closeddate = ' empty space' and have tried the following select * from ticket where Type = 'Line' and Closeddate = 'Null' select * from ticket where Type = 'Line' and Closeddate = 'NULL' any clues -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Query problem
Assuming you run MySQL, why don't you just remove the " ' "? SELECT * FROM MyTable WHERE MyField=NULL Sincerely berber Visit http://www.weberdev.com/ Today!!! To see where PHP might take you tomorrow. Share your code : http://addexample.weberdev.com -Original Message- From: Ron Allen [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 22, 2003 11:29 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Query problem I have done this in the past, but for some reason it isn't working now (maybe a moron). I am trying to select all of the empty or NULL fields in a column. This is what I have select * from ticket where Type = 'Line' and Closeddate = ' empty space' and have tried the following select * from ticket where Type = 'Line' and Closeddate = 'Null' select * from ticket where Type = 'Line' and Closeddate = 'NULL' any clues -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Query problem
How would the entire query look select * from ticket where Type = 'Phone' and ??? "Dirk Kredler" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Am Dienstag, 22. Juli 2003 11:29 schrieb Ron Allen: > > This is what I have > > select * from ticket where Type = 'Line' and Closeddate = ' empty space' > > and have tried the following > > select * from ticket where Type = 'Line' and Closeddate = 'Null' > > select * from ticket where Type = 'Line' and Closeddate = 'NULL' > > use > > isNULL(Closedate) instead of Closedate = 'NULL' > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Query problem
select * from ticket where Type = 'Line' and (Closeddate IS NULL OR Closeddate ='') or select * from ticket where Type = 'Line' and Closeddate IS NULL HTH Peter -Original Message- From: Ron Allen [mailto:[EMAIL PROTECTED] Sent: 22 July 2003 10:29 To: [EMAIL PROTECTED] Subject: [PHP-DB] Query problem I have done this in the past, but for some reason it isn't working now (maybe a moron). I am trying to select all of the empty or NULL fields in a column. This is what I have select * from ticket where Type = 'Line' and Closeddate = ' empty space' and have tried the following select * from ticket where Type = 'Line' and Closeddate = 'Null' select * from ticket where Type = 'Line' and Closeddate = 'NULL' any clues -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Query problem
Am Dienstag, 22. Juli 2003 11:29 schrieb Ron Allen: > This is what I have > select * from ticket where Type = 'Line' and Closeddate = ' empty space' > and have tried the following > select * from ticket where Type = 'Line' and Closeddate = 'Null' > select * from ticket where Type = 'Line' and Closeddate = 'NULL' use isNULL(Closedate) instead of Closedate = 'NULL' -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] query problem
On Tuesday 22 January 2002 13:18, Sommai Fongnamthip wrote: > Hi, > I have problem with these mysql's query: > > select * from holder, management where holder.id=management.id or > (holder.name=management.name and holder.surname=management.surname) order > by holder.no > > It take a long time (more than 1 minute) with thousand record. I have > index within 2 table (name+surname, id). It did not have problem if I > check only id or name+surname. This is a mysql question. Perhaps you should ask on the mysql list. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* One expresses well the love he does not feel. -- J.A. Karr */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Query problem cont'd..
ok. try this. ahven't tested it though ... ?".$months[$x-1]."\n"; } echo ' '; ?> then something like (pref before the dump of months) will be populated when the form refreshes and then isset() will say it has a value and drop inside to create the query. that way you avoid an expensive if or or or or ... Steve > -Original Message- > From: Russ Michell [mailto:[EMAIL PROTECTED]] > Sent: 26 April 2001 10:50 > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Query problem cont'd.. > > > Hi there: > > I'm stil having problems with this query in that it doesn't > bring up any results! > Here is the menu that refreshes the page and > deposites the var: 'sortedBy' into play: > > --select one-- > Jan > Feb > Mar > Apr > May > Jun > Jul > Aug > Sep > Oct > Nov > Dec > > > > The SQL qery: > > if( > ($sortedBy == 'Jan') || ($sortedBy == 'Feb') || ($sortedBy == > 'Mar') || > ($sortedBy == 'Apr') || ($sortedBy == 'May') || ($sortedBy == > 'Jun') || > ($sortedBy == 'Jul') || ($sortedBy == 'Aug') || ($sortedBy == > 'Sep') || > ($sortedBy == 'Oct') || ($sortedBy == 'Nov') || ($sortedBy == 'Dec') > ) > { > $sql = "SELECT * FROM $table_cal WHERE item_activity='$id' AND > DATE_FORMAT('item_date','%b')='$sortedBy'"; > } > > Thanks to Rasmus for helping me out so far! > Can anyone see what I may be doing wrong??? > > I'm using mysql-3.22.32 and the item_date column is a MySQL > DATE() column.. > > Cheers: > Russ > > #---# > > "Believe nothing - consider everything" >"Web Developers do it on-the-fly." > > Russ Michell > Anglia Polytechnic University Webteam > > e: [EMAIL PROTECTED] > w: www.apu.ac.uk/webteam > t: +44 (0)1223 363271 x 2331 > > www.theruss.com > > #---# > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: > [EMAIL PROTECTED] > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] query problem
> My PHP-embedded query is as follows: > > else if($sortBy == '01') { > $sql = "SELECT * FROM $table_cal WHERE item_activity='$id' AND >DATE_FORMAT('item_date','%m') LIKE '$sortBy'"; > $sortBy = "Month of January"; > } > > * '$sortBy' is equal to '01'. > * MySQL isn't complaining about any of the query. > * DATE_FORMAT('item_date','%m') should be '01' (taken from > a 'date' column in -MM-DD fromat. > > Can anyone tell me what is wrong with this query (I may have missed > something - but then that shouldn't surprise as I've been staring at it > for 3 hours...;-) Nothing jumps out at me except for the fact that you are using LIKE without any sort of wildcard in the actual '01' string. If you don't have a wildcard of any sort, just use = instead of LIKE -Rasmus -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]