This tag will generally be used by those unfamiliar with SQL, asking basic questions about joins. In SQL, data is stored in tables. Frequently, queries need data from multiple tables, and the way that they are connected may not be obvious.
Questions tagged [multiple-tables]
823 questions
0
votes
2 answers
mysql_fetch_assoc vs iterative mysql_fetch_row & mysql_fetch_column
I am working on an active record class that is used to fetch records from a database which can contain joins.
Now, in my tests, I have had some data that has common column names that contain different values, but when I perform a mysql_fetch_assoc…

topherg
- 4,203
- 4
- 37
- 72
0
votes
1 answer
PHP/MySQL Multi table selections
I'm trying to select multiple rows from one table, depending on the ID given from another table.
I've got it half working with the code below, however it echo's out each blog multiple times depending on how many different tags are assigned to it,…

Newcastlefan
- 39
- 3
- 10
0
votes
1 answer
Joining Another Table in Select Statement Yields Incorrect Higher Aggregate Totals
Straight forward aggregate select statement I am having trouble with.
When I first run this query, no problems:
SELECT distinct
t2.primary_insurance [Primary Insurance]
,COUNT(t2.account_number) [Volume]
,SUM(t2.los) [Total LOS]
,AVG(t2.los)…

tonytone
- 71
- 1
- 11
0
votes
2 answers
How to search in multiple tables using codeigniter?
So i have a searchbox to search in my factories table. it works like a charm, but i'm still new to codeigniter.
Do i need to use a select to select more than one table in my database?
My controller function:
function search()
{
…

Kees Sonnema
- 5,759
- 6
- 51
- 106
0
votes
1 answer
trying to pull from multiple tables and displaying the different information
So I have been searching and doing trial and error for several days now, and Im turning to here for help.
I have created a page on my website that pulls a schedule information from a table on a database and displays it to the webpage. I am trying to…

Chad
- 1
- 2
0
votes
2 answers
Finding the id from the highest date when multiple dates are present
When I run this query I get:
SELECT DISTINCT r2.ApplicationBK,
max(r2.DatumApplication) maxdatum,
p.Name
FROM FCT_Recruitment r2,
DIM_WervingsProject wp,
DIM_Persoon p
WHERE r2.WervingsProjectID =…
0
votes
0 answers
How to create a mysql loop of multiple table names structure and data copy to second database
What I'm trying to accomplish.
My site is live, and I'm making some changes to it.
When I'm ready to go live with the changes, I will essentially drop the old database (myFirstDb) and put the new one up(mySecondDb).
BUT - I will want to keep a few…

Acts7Seven
- 417
- 1
- 6
- 14
0
votes
1 answer
sql query - how to join/union 3 tables (2 index tables and 1 data table)
i got 3 tables, 2 index tables and 1 data table
tables' structure is like this:
users:
id | name
--------+-----------
1 | John
2 | Mike
3 | James
idx and idx2:
user_id | user_id2 | action |…

dimaninc
- 765
- 5
- 16
0
votes
2 answers
Need help joining two tables by guid then adding values across columns by row
I have two tables.
One table stores items and their cost and are stored uniquely with their own guid.
ItemCost Table
Item_ID ItemCategory Item Cost
x-xx-x Computer Laptop 400.00
The other table stores a work space that is a…

user2187945
- 3
- 1
- 2
0
votes
3 answers
Denormalising a fully normalised table
Can anyone advise on how to go about denormalising a fully normalised table? I've not been able to find much on it despite googling.
Whenever a record is updated (though not inserted, but lets not worry about that now) in TableA a record is inserted…

atamata
- 997
- 3
- 14
- 32
0
votes
1 answer
SQL CSV import/export post data across tables
I need to:
Join wordpress data from multiple tables so all data pertaining to each post resides on a single row for export to CSV.
and
Split data back across the tables during import of the CSV.
I believe this can by done via 2 mySQL queries.
My…

timoto
- 55
- 10
0
votes
1 answer
Using multiple tables mysql
Ok so I have 3 tables
1.phone:
id
name
manufacturerid
osid
2.manufacturer
manufacturerid
manufacturername
3.os
osid
osname
How can i put the data from one of the tables (manufacturerid1 -> manufacturerid2 and osid1>osid2) to the the…

Snyckey
- 1
- 2
0
votes
3 answers
select result from three tables using sql
I want to get a result from three tables. i dont how to write the sql query. Please help me.
"I want to display Name,Username and Product_Name where Id=007"
table "register"
Name Username Id
Arj arjun 007
xyz abcd 008
abcd asdf …

ARJUN
- 21
- 1
- 2
- 4
0
votes
2 answers
MySQL three-table join
I have three tables called Clinic, Doctor, and Clinic_has_Doctor. Suppose the two tables Clinic and Doctor have fields id and name as follows:
Clinic
+----+------------------------+
| id | name …

mavili
- 3,385
- 4
- 30
- 46
0
votes
2 answers
mysql insert if condition true
First, here's the concise summary of the question:
Is it possible to run an INSERT statement conditionally? Something akin to this:
IF(expression) INSERT...
Now, I know I can do this with a stored procedure.
Now, I want to do that
Let's assume we…

user2001057
- 158
- 7