View Full Version : data from2tables
gurmeet
12-27-2009, 09:08 AM
hi,
i have 2 tables,data is stored and i want to retrieve data from 2 tables in a single query, is it possible to achiev it?
table 1
id - visit
1
2
3
.
3
2
3
.
.
-------------------
table 2
id - meeting
1
2
3
4
1
2
3
4
.
.
.
---------------
tables are just like this, both IDs are having samelike value.
nowiwant to get the IDS of those 5 persons who have more visits and meeting,but i want in a single query...plz help
djr33
12-27-2009, 05:10 PM
The easiest way to do any of this (more than one table) is to just take it one step at a time and then query again in PHP to narrow it down. There may be complex ways in mysql, but php would probably be easier to work with, if a little slower (doing multiple, bigger queries).
So, get all the meetings. Then get all the visits. Then compare the two in PHP and see what you get.
gurmeet
01-01-2010, 02:50 PM
The easiest way to do any of this (more than one table) is to just take it one step at a time and then query again in PHP to narrow it down. There may be complex ways in mysql, but php would probably be easier to work with, if a little slower (doing multiple, bigger queries).
So, get all the meetings. Then get all the visits. Then compare the two in PHP and see what you get.
yes its easy...
but i want to calculate the data on back end, if i compare it with PHP and the result is not satisfactory then again i have so send more queries to get more data...
so i want to compare and get data from two tables at a time b after comparing on the back end...
djr33
01-01-2010, 07:49 PM
If you must do it with mysql, then take a look here:
http://www.tizag.com/mysqlTutorial/mysqljoins.php
The problem is that while you may be able to setup a basic mysql-only script, if you ever need to modify it things can get very complex. I hope that tutorial at least gets you started.
Also, I do think this could be done well in php (maybe not quite as efficiently), if you make sure you don't need to query again afterward.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.