ket — 2010-01-13T23:59:44-05:00 — #1
Need a bit of help with an easy mysql query.
I have a database with two tables:
- one table named "clients" which has 5 columns (id_client, name, address, date, and phone)
- the other table named "cards" which has 5 columns as well (id_card, bank, type, category, id_client)
The "type" column on the "cards" table is ENUM and can either be "gold" or "normal". (it's related to the type of bank card.. visa, gold, etc..)
I need a query that shows the name of the clients that have the "gold" card.
Any ideas? Thanks! :eye:
r937 — 2010-01-14T00:05:51-05:00 — #2
ket — 2010-01-14T00:08:02-05:00 — #3
i'm trying as we speak. i'm suppose to use inner join, right?
r937 — 2010-01-14T00:13:29-05:00 — #4
ket — 2010-01-14T00:16:58-05:00 — #5
i've tried the following code with no success, still reading more about it..
SELECT cards.type, clients.name
INNER JOIN clients ON cards.type= clients.id_cliente
WHERE cards.type= 'gold'
do i need to SELECT the clients.id_client as well?
ket — 2010-01-14T00:24:39-05:00 — #6
after reading and checking this example, i was able to create the following query:
SELECT clients.name, cards.type, cards.id_client
INNER JOIN cards
ON clients.id_client = cards.id_client
WHERE cards.type = 'gold'
r937 — 2010-01-14T00:30:14-05:00 — #7
what happened when you tested it?
ket — 2010-01-14T00:33:53-05:00 — #8
well, it displayed the names of the clients that have the Gold card, just like i wanted (:
r937 — 2010-01-14T00:39:29-05:00 — #9
glad i could help
ket — 2010-01-14T00:40:44-05:00 — #10
eheheh rudy, thanks for the help