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
2
votes
3 answers
mysql select query on two tables
I am trying to get a result from two tables without having a second query nested inside the first query loop.
I have a table products:
product_code_1234 | product_name | otherfields...
And a table categories, where a product can have multiple…

Sclerato
- 155
- 2
- 2
- 6
2
votes
3 answers
2-table interaction: insert, get result, insert
I need to make a fundamental decision of my database/web interaction and I am missing the knowledge to even find proper search terms.
Background:
I am building a family website which supports a forum, family tree, pvp games with rankings and more…

Rusty75
- 477
- 7
- 19
2
votes
1 answer
MySQL SELECTing certain rows depending on IF/CASE statement
something like the following is what I'm looking to do
SELECT id, status, Gid, Uid, note FROM notes LIMIT 10
but the status id could be different and it would need to be something like the following
SELECT a.id, a.status, a.Gid, a.Uid, a.note
FROM…

Yohn
- 2,519
- 19
- 23
2
votes
1 answer
Removing tables with a join in SQL Server
I'm new to this DBA thing and I've been tasked with removing duplicates from a couple of tables. I'm working in SQL Server. They all have a field called LAST_UPD that tracks their last update. All the tables join to TABLE1 and each user is…

Fear605
- 35
- 5
2
votes
1 answer
How do I combine data from two MySQL tables to return a list of users sorted by the count of user entries in one table?
I am currently using this MySQL query:
$query="SELECT user, COUNT(*) AS num FROM tracks GROUP BY user ORDER BY COUNT(*) DESC";
which gives me a unique row for each user with a count of the number of entries for each user in the table 'tracks'.
Not…

Nick
- 4,304
- 15
- 69
- 108
2
votes
1 answer
lapply with condition?
I try to do a function which works with for loops with lapply instead. I am very new to R and not confortable with lapply. I especially don't get how to make an "if" condition.
My current code with for loops looks like that (it nomalizes volume…

VincentH
- 1,009
- 4
- 13
- 24
2
votes
2 answers
Grab value from multiple tables, use count and group by
I'm trying to output some data in MSSQL from 3 different tables (status, status & cases) in 2 different databases (global & private).
global.status // contains labels for global status ID's
fields (id, text)
private.status // contains…

Rudi Hansen
- 124
- 7
1
vote
1 answer
How to add two tables data into a Crystal Report in c#
I am using Access database as datasource. There are two tables in my database . One is Product Table and Invoice table. Invoice table has a productId which is actually Id in the product table. I want to show the product name instead of id dynamicaly…

las
- 196
- 8
1
vote
2 answers
SQL - Foreign key referencing different tables' primary key (Postgres)
This is for a project. I am making up a database for different kinds of records for an office. There is a table collecting all the primary keys of those record tables. So, I need to have a foreign key referencing those tables. And I am lost. I asked…

Jinnean
- 97
- 1
- 11
1
vote
1 answer
get columns from multiple tables from multiples entities in Silverlight
I would like to create a datagrid which would contains 5 columns.
Each column from a different table and each table is from a different entity.
How should i do that in silverlight ?
I'm actually able to get the data from 1 table and display it in…

Oliver
- 807
- 2
- 12
- 23
1
vote
4 answers
Select columns from various tables in mySQL
I have a dynamic list of categories, which is retrieved from mySQL. When the user is clicking on a category, it loads images for that specific category from the DB. This is the function that does it:
function getImages($categoryID)
{
return…

Igal
- 5,833
- 20
- 74
- 132
1
vote
1 answer
Multiple INNER JOINs SQL Server Compact Edition
I am trying to do multiple joins within a single query in SQL Server CE. I know that SQL Server CE doesn't support multiple SELECTs but I can't find any information on multiple INNER JOINs. I keep getting token errors on ProjectItemMaster (after the…

Calidus
- 1,374
- 2
- 14
- 31
1
vote
1 answer
Multiple keywords, multiple tables. How should my SQL look like? (screenshot attached)
I have these tables in my database:
Contacts
-contact_id
-contact_name
File
-file_id
-file_code
-customer_id
-hauler_id
File_details
-file_id
-loadunload_id
-loadunload_date
-loadunload_time
LoadUnload
…

Nerdben
- 68
- 5
1
vote
3 answers
mysql query select from multiple, order by date
What's a good and simple way to select from multiple tables and just order everything by date, newest to oldest?
mysql_query("
SELECT *
FROM posts, comments, photos
WHERE userID='$session'
…

Dylan Cross
- 5,918
- 22
- 77
- 118
1
vote
3 answers
How do I (SELECT) populate two objects from two tables with a single query?
This should be something encountered by programmers often, but I never tried to get things this way.
That is, I'll explain. Say, I need to fetch values from table Zoo like this:
@"SELECT z.predator, z.prey FROM Zoo AS z WHERE…

nawfal
- 70,104
- 56
- 326
- 368