Help with easy mysql query - show name of clients with "gold" card

Hello fellas,

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:

what have you tried?

hi r937,

i’m trying as we speak. i’m suppose to use inner join, right?


yes :slight_smile:

i’ve tried the following code with no success, still reading more about it…

SELECT cards.type,
FROM cards
INNER JOIN clients ON cards.type= clients.id_cliente
WHERE cards.type= ‘gold’

do i need to SELECT the clients.id_client as well?

after reading and checking this example, i was able to create the following query:

SELECT, cards.type, cards.id_client
FROM clients
ON clients.id_client = cards.id_client
WHERE cards.type = ‘gold’

correct? right?

what happened when you tested it? :slight_smile:

well, it displayed the names of the clients that have the Gold card, just like i wanted (:

glad i could help


eheheh rudy, thanks for the help :wink: