Reputation: 61
i got a problem when i select all table with query.
this is the code of query:
SELECT *
FROM user, pendidikan, cv, foto, data_pribadi
WHERE pendidikan.id
and user.id
and cv.id
and foto.id
and data_pribadi.id = 1
when i use that query, i get much data not just id = 1. how i get just table from user, pendidikan, cv, foto, data_pribadi but just id = 1??
just information : id is foregn key from table : pendidikan, cv, foto, data_pribadi and id primary key from table user
Upvotes: 0
Views: 34
Reputation: 48187
Use JOIN
sintaxis something like this depending on how is the relationship betwen tables.
SELECT u.* --, p.*, c.*, f.*, d.* select what fields you need
FROM user u
JOIN pendidikan p
ON u.pendikan_id = p.pendikan_id
JOIN cv c
ON u.cv_id = c.id
JOIN foto f
ON u.foto_id = f.foto_id
JOIN data_prabgadi d
ON u.data_prabgadi_id = d.id
WHERE d.id = 1
Upvotes: 1