query of 2 tables

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

query of 2 tables

Post by pelegk2 »

query of 2 tables
i have this tables :


quote:
--------------------------------------------------------------------------------

Prd
p_makat name
1 aaa
2 bbb
3 ddd

tbl
P_makat Set_no
1 4
2 3


--------------------------------------------------------------------------------



this is the result



quote:
--------------------------------------------------------------------------------

P_makat Set_no
1 4
2 3
3 NULL

--------------------------------------------------------------------------------



2 questions :
1)how can i get the result from the first 2 tables?
2)how can i get for example the result of p_makat=3
from table 1 even if it dosent exist in table 2?
so i will see al table 1 detailes and from table 2 i will see that the valu dosent ecist?
thanks in advane
peleg
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

I think this will work:

Code: Select all

SELECT
  prd.p_makat,
  tbl.set_no
FROM prd
LEFT JOIN tbl ON tbl.p_makat = prd.p_makat
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

i added w where and it didnt help :

Post by pelegk2 »

i did L:

Code: Select all

SELECT
  common.products.p_makat, 
  tblweightstations.set_no 
FROM common.products 
LEFT JOIN tblweightstations ON tblweightstations.p_makat = common.products.p_makat  where tblweightstations.p_makat='6502'

opppsssssory it workd great now:)
thanks *1000000000000000000000$
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

You'r wellcome
Post Reply