Jump to content


more then one "where" ?


4 replies to this topic

#1 Veng

    Young Padawan

  • Members
  • Pip
  • 12 posts

Posted 02 March 2006 - 12:06 PM

justed learned to use the "where"
( like $query="SELECT * from news where approved = 1"; )
But is it possible to use 2 of these? ( like $query="SELECT * from news where approved = 1 where author = Nick"; )

...sorry for my bad english...

#2 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 02 March 2006 - 12:17 PM

yes it would be:

SELECT * FROM `news` WHERE `approved` = '1' AND `author` = 'Nick'

Just stick the AND in there, and you can use it as many times as you need!

Edited by deadly, 07 March 2006 - 02:26 AM.


#3 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 02 March 2006 - 12:37 PM

Same question and answer :)
http://www.pixel2lif...showtopic=18703

In short, just read this:
http://dev.mysql.com...cting-rows.html

#4 Lang

    Young Padawan

  • Members
  • Pip
  • 198 posts
  • Gender:Male
  • Location:Ontario, Canada

Posted 06 March 2006 - 04:13 PM

Woah two where clauses is WRONG!

Quote

SELECT * FROM `news` WHERE `approved` = '1' AND WHERE `author` = 'Nick'

Don't listen to that. If it works that's great but that is just TERRIBLE practice.

SELECT * FROM blah WHERE condition = 1 AND this = 2 OR this = 3


#5 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 07 March 2006 - 02:26 AM

opps i didnt see i put 2 Where's in, i meant what lang put, only need the one Where clause lol





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users