•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 392,068 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,236 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 441 | Replies: 1
![]() |
•
•
Join Date: Jul 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
It's took me a weeks to figure out this query.
I'm trying to select all the data from 7 tables but i got empty result. All these table has a link on region_id column.
Your help will be much much appreciated.
here's my query:
If you need more information about my table then I can post it.
Thank you for your time.
Finau
It's took me a weeks to figure out this query.
I'm trying to select all the data from 7 tables but i got empty result. All these table has a link on region_id column.
Your help will be much much appreciated.
here's my query:
$q = 'SELECT rs.*,rr.*,cs.*,cr.*,cl.*,ls.*,ll.* FROM
tbl_residential_sale as rs,
tbl_residential_rent as rr,
tbl_commercial_sale as cs,
tbl_commercial_rent as cr,
tbl_commercial_lease as cl,
tbl_land_sale as ls,
tbl_land_lease as ll
WHERE
rs.start_date IS NOT NULL AND rs.expire_date >= NOW() AND rs.region_id=1
AND
rr.start_date IS NOT NULL AND rr.expire_date >= NOW() AND rr.region_id=1
AND
cs.start_date IS NOT NULL AND cs.expire_date >= NOW() AND cs.region_id=1
AND
cr.start_date IS NOT NULL AND cr.expire_date >= NOW() AND cr.region_id=1
AND
cl.start_date IS NOT NULL AND cl.expire_date >= NOW() AND cl.region_id=1
AND
ls.start_date IS NOT NULL AND ls.expire_date >= NOW() AND ls.region_id=1
AND
ll.start_date IS NOT NULL AND ll.expire_date >= NOW() AND ll.region_id=1';Thank you for your time.
Finau
Last edited by Tekmaven : 32 Days Ago at 4:12 am. Reason: Cod
•
•
Join Date: Apr 2008
Posts: 295
Reputation:
Rep Power: 1
Solved Threads: 41
Hi Finau,
If both following statements are true
1. Each table has a column named region_id of compatible data type
2. At least one of those tables has primary key region_id AND all other
tables containing region_id that column is attributed to be foreign key.
then you may carry out this sql statement
to get a first result. Afterwards you can add some further predicates, like cr.start_date IS NOT NULL AND cr.expire_date >= NOW()..., to where-clause for reducing result set.
I really doubt a little that each table has column region_id. You may post the creating statements of your seven tables.
Btw, your select statement seriously lacks of join constraints which must be added to where-clause, as for example: where rs.joining-column = rr.joining-colum etc. If you omit such constraints you will get a undesirable cross products (cartesian products).
-----
tesu
If both following statements are true
1. Each table has a column named region_id of compatible data type
2. At least one of those tables has primary key region_id AND all other
tables containing region_id that column is attributed to be foreign key.
then you may carry out this sql statement
select * from tbl_residential_sale as rs join tbl_residential_rent as rr
join tbl_commercial_sale as cs join tbl_commercial_rent as cr
join tbl_commercial_lease as cl join tbl_land_sale as ls
join tbl_land_lease as llI really doubt a little that each table has column region_id. You may post the creating statements of your seven tables.
Btw, your select statement seriously lacks of join constraints which must be added to where-clause, as for example: where rs.joining-column = rr.joining-colum etc. If you omit such constraints you will get a undesirable cross products (cartesian products).
-----
tesu
Last edited by tesuji : 31 Days Ago at 2:20 pm.
Information is moving—you know, nightly news is one way, of course, but it's also moving through the blogosphere and through the Internets. I promise you I will listen to what has been said here, even though I wasn't here. Ann and I will carry out this equivocal message to the world. I'm the master of low expectations.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
Similar Threads
- How do you SELECT multiple tables from mysql ? (PHP)
- How to select multiple fields from a joined table (MS SQL)
- Searching Multiple tables... Please help me!!!!! (PHP)
- data from multiple tables (VB.NET)
- Query multiple tables? (MySQL)
Other Threads in the MySQL Forum
- Previous Thread: Mysql error
- Next Thread: Do I need to know MySQL


Linear Mode