Forum Moderators: coopster

Message Too Old, No Replies

Mysql Query Prob

         

umerkk

9:01 am on Jun 24, 2007 (gmt 0)

10+ Year Member



Hi I want a mysql querry which show me result like

Select * from Bb Where Pd = '104' AND MsgFrom = 'umer@example.Com' AND TO = 'umer@example.com'

When i add AND two times in query it show me erro, Anyone can help me out that how can i check that on BB where Pd is 104 and msgfrom is Umer@example.com and to field is equal to umer@example.com

Thanks in Advance

[edited by: eelixduppy at 1:42 pm (utc) on June 24, 2007]
[edit reason] example.com [/edit]

Frank_Rizzo

10:47 am on Jun 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



AND TO = 'umer@example.com'

the TO seems to be your problem.

Shouldn't it be something like

AND MsgTo

[edited by: eelixduppy at 1:43 pm (utc) on June 24, 2007]
[edit reason] example.com [/edit]

henry0

11:27 am on Jun 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"TO" is causing your query to fail
"TO" is a "reserved" word
you are not allowed to use it, and you need to rename it.

Gian04

1:27 pm on Jun 24, 2007 (gmt 0)

10+ Year Member



Select * from Bb Where Pd = '104' AND MsgFrom = 'umer@example.Com' AND `TO` = 'umer@example.com'

[edited by: eelixduppy at 1:43 pm (utc) on June 24, 2007]
[edit reason] example.com [/edit]

eelixduppy

1:57 pm on Jun 24, 2007 (gmt 0)



TO is indeed a reserved word [dev.mysql.com]. You can still use it, as shown above, by escaping it with the prime character(`), however, it is best to avoid using reserved words as column names as much as possible, so changing won't hurt, unless it will cause a lot of work for you. Just keep it in mind in the future :)

umerkk

5:34 pm on Jun 24, 2007 (gmt 0)

10+ Year Member



Ok i solved it out, But What if i want to execute 2 kind of query at a time like

Select * from PD = 'umer@examle.com' WHERE parentbd = '104' and msgfrom = 'umer@example.com' and msgto = 'san@example.com'

Or and also Reversily like

Select * from PD = 'umer@examle.com' WHERE parentbd = '104' and msgfrom = 'san@example.com' and msgto = 'umer@example.com'

eelixduppy

9:23 pm on Jun 24, 2007 (gmt 0)



Neither of those queries are valid. Are you trying to update the row? In you want to update multiple rows at the same time, you can use the IN function [dev.mysql.com] with a correctly formated UPDATE query [dev.mysql.com].

henry0

9:46 pm on Jun 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



eelix I cannot find where we have that "tutorial" thread with most of the MySQL query, insert, update etc...

would you point ummerk to that post

I think he looks for ¦¦ or OR
(Forum breaks pipes)

eelixduppy

9:49 pm on Jun 24, 2007 (gmt 0)



>> would you point ummerk to that post

You mean this one?: [webmasterworld.com...] :)