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
12
votes
4 answers
How to update column in a table from another table based on condition?
I am having two tables
student table it contains (Student_id,school_code,name,year,...)
school table it contains (school_id,School_code,School_name,year
etc.....)
I want to update the school_code column in the student table with the school_id…

Pavi
- 335
- 2
- 3
- 20
10
votes
3 answers
Django - Generate excel reports based on model fields
The application is built on django/angular. I want to generate a excel report based on model and it's fields selected by users. You can find search UI below. I have 4 models in django. Coach, Player, Participation which have foreign key reference…

MysticCodes
- 3,092
- 5
- 25
- 33
10
votes
1 answer
Scrapy: Suggestion for Multiple Returns/Items to Database
To further elaborate on the heading for this question: I am scraping info off of movie website. I currently have a MySQL database populated with movie titles, movie urls, etc. I'm now going to take those urls from the database and set them as my…

DMML
- 1,422
- 4
- 22
- 39
9
votes
4 answers
How to do Outer Join on >2 Tables (Oracle)
I'm not sure how to describe my table structure, so hope this makes sense...
I have 3 tables in hierarchical relationship such that A has a one to many relationship to B which in turn has a one to many relationship with C. The trick is that the…

sdoca
- 7,832
- 23
- 70
- 127
8
votes
3 answers
MySQL select DATETIME similar up to the minute
I have to comapre the results relative to the same time between two tables, but the time stamps differs of some second because of how they were recorded.
I would like to obtain a result like in Example 1 but I get only the values with the asterisk,…

Andrew Strathclyde
- 327
- 4
- 10
- 23
8
votes
1 answer
ASP.NET MVC 3 multiple Models to single Form
I'm learning ASP.NET MVC 3 and trying to create a View with a single form which is made up of multiple Models linked together by a foreign key. The end goal is to have the single form insert into all the database tables.
The problem is that I cannot…

user764662
- 83
- 1
- 1
- 3
8
votes
2 answers
How can I have two columns in one table point to the same column in another with ActiveRecord?
I run the risk of palm-to-forehead here, but I can't quite figure out how to do this with Rails' ActiveRecord sugar.
I have a tickets table that has two columns (submitter_id and assignee_id) that should each reference a different user from the…

localshred
- 2,244
- 1
- 21
- 33
7
votes
3 answers
MySQL Keyword Search Across Multiple Tables
I have three tables in a MySQL database used in a music library application:
The Genre table has columns:
id
title (string)
The Album table has columns:
id
genre_id (foreign key to Genre.id)
title (string)
artist (string)
and the Track table has…

Eric Freese
- 1,485
- 2
- 13
- 25
7
votes
4 answers
mysql select/delete using join over four tables
I have four tables (in [] are columns):
users [id]
products [id]
productRatings [id,value,user,product]
comments [id,product,user]
I would like to select/and ultimately delete productRatings where there are no associated comment by the same user for…

dbr
- 1,037
- 14
- 34
7
votes
1 answer
Delete from table if the id doesn't exists in another table
I want to delete the id's from types that can't be found in types_photos but I don't know how I can accomplish this. id_type in types_photos are the same as id in types. Here's how the table's structure looks like:
CREATE TABLE IF NOT EXISTS `types`…

Airikr
- 6,258
- 15
- 59
- 110
7
votes
1 answer
Multiple joins/merges with data.tables
I have two data.tables, DT and L:
> DT = data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9,key="x")
> L=data.table(yv=c(1L:8L,12L),lu=c(letters[8:1],letters[12]),key="yv")
> DT
x y v
1: a 1 1
2: a 3 2
3: a 6 3
4: b 1 4
5: b 3 5
6: b 6…

dnlbrky
- 9,396
- 2
- 51
- 64
6
votes
2 answers
Create fulltext index on a VIEW
Is it possible to create a full text index on a VIEW?
If so, given two columns column1 and column2 on a VIEW, what is the SQL to get this done?
The reason I'd like to do this is I have two very large tables, where I need to do a FULLTEXT search of a…

kylex
- 14,178
- 33
- 114
- 175
6
votes
5 answers
Foreign key with multiple columns from different tables
Let's take a stupid example : I have many domestic animals, each one with a NAME as an id and a type (being CAT or DOG), let's write it this way (pseudo code) :
TABLE ANIMALS (
NAME char,
ANIMAL_TYPE char {'DOG', 'CAT'}
PRIMARY…

user1695584
- 63
- 1
- 1
- 3
6
votes
2 answers
Fetching single value from SQLite in android
I'm developing my firs app for android right now, I am using multiple tables to get and insert data. during the development and found myself fetching data from the table with has only two columns STATS(_id, stat_name). What my problem is? I have an…

mancuss
- 365
- 1
- 4
- 14
5
votes
2 answers
Need help with PHP and MySQL
I have a table of songs, some songs are album song, and some are singles...
And I have a table of albums...
Example:
if the album ID is [null], it means the song is a single
Songs…

Andy
- 51
- 2