Jump to content


Photo

where clause problem!


  • Please log in to reply
2 replies to this topic

#1 DjNaF

DjNaF
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 25 March 2006 - 09:10 PM

hello;

i have this table (restcards_tbl) ,
both are primary keys
+--------+--------+
| restid | cardid |
+--------+--------+
| 1 | 1 |
| 1 | 2 |
| 1 | 4 |
| 1 | 6 |
| 15 | 1 |
| 15 | 2 |
| 15 | 3 |
| 15 | 4 |
| 15 | 12 |
+--------+--------+

and this table (cards_tbl)

+--------+------------------+
| CardID | CardName |
+--------+------------------+
| 1 | Visa |
| 2 | Master Card |
| 3 | American Express |
| 4 | GO Card |
| 5 | Golden Card |
| 6 | Green Card |
| 7 | Silver Card |
| 12 | Bronze Card |
+--------+------------------+

every restaurant have an id RESTID.
and CARDID means , the id of the cards accepted in the restaurants.

i want a coide that the user can search for the restaurants that accepts for example
Visa AND MasterCard AND American Express

and it displayes the id for those restaurants!

i tried
select restid from restcards_tbl where cardid=1 and cardid=2 and cardid=3

but no results :(
if any1 has a php code to help me display results i'd be grateful

Thank you


#2 azuka

azuka
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts
  • LocationNigeria

Posted 26 March 2006 - 01:10 AM

use "OR" ie:
select restid from restcards_tbl where cardid=1 or cardid=2 or cardid=3

Given enough eyeballs all bugs are shallow. My Website

#3 DjNaF

DjNaF
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 26 March 2006 - 05:46 PM

I want the resdtaurant that has 1 AND 2 AND 3 together!
OR will list all restaurants that have 1 alone and 2 alone, and 3 alone
I DONT want that!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users