...

View Full Version : How to make this search?



xiaodao
09-06-2007, 04:25 AM
Hi, my table is like this

[blktable]
blkid
blkname

[flattable]
flatid
flatnumber
blkid

[occupant]
oid
occupant
flatid

how can i get occupant, flatnumber, blkname is a single sql search, how to do?

iota
09-06-2007, 01:59 PM
Easy stuff!
I rename table names for clarity.



SELECT occupant, flatnumber, blkname
FROM table_blk, table_flat, table_occupant
WHERE
table_occupant.flatid = table_flat.flatid AND
table_flat.blkid = table_blk.blkid


Some Database Concept

1. Draw ERD.
2. Identify Relationships between entities like 1-1 or 1-*.
3. Write SQL Where statement by tracing top-down or bottom-up approach.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum