Questions tagged [multiple-tables]

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.

823 questions
2
votes
1 answer

SQL - join multiple tables, with one little catch

My apologies in advance if this particular question has already been asked and answered ... there so many different particular ways the JOIN command is used that it can be difficult to find the exact answer to a given problem. I'm a SQL novice, so…
Grant M.
  • 233
  • 1
  • 3
  • 8
2
votes
2 answers

complex MySQL query with multiple tables (read for more details)

I have 4 tables: Teams, Users, UserTeams and Permissions: Users: UserID | Name ------------------------ 1 | John 2 | Mike 3 | Tom Teams: TeamID | Name ------------------------------- 1 | FC Barcelona 2 | Real Madrid 3 …
Hese
  • 291
  • 5
  • 18
2
votes
1 answer

Mysql select multiple tables but inner join on one table

Is it possible to select multiple tables and make inner join on one of those tables? e.g. SELECT * FROM table1 AS t1, table2 AS t2, table3 AS t3 INNER JOIN table4 AS t4 ON t1.row3 = t4.row3 INNER JOIN table5 AS t5 ON t1.row4 = t5.row4 WHERE…
woopata
  • 875
  • 5
  • 17
  • 29
2
votes
6 answers

how to select data from multiple tables?

I have 4 tables, i am very confused to select the data. I have this fields in my 4 tables t1 -> student_id given_name user_name t2 -> school_year sem class student_id main_id t3 -> subject_id main_id t4 -> subject_id …
apssiva
  • 33
  • 1
  • 4
2
votes
2 answers

Multiple DB-Tables in Repository - How to do this?

I have the following Code: Controller class UserController { public function __construct(userRepository $userRepository) { $this->userRepository = $userRepository; } [...] Repository class UserRepository extends…
TheQuestionmark
  • 69
  • 1
  • 10
2
votes
1 answer

Querying multiple MySQL tables based on distinct values, and return the matches count and time difference between first and last record

Question Summary I need to select all distinct values of column slug in a table, then go through other multiple tables, and for each count the records where slug appears, as well as find the difference in days between the first and last…
MAR
  • 553
  • 2
  • 7
  • 17
2
votes
2 answers

MySQL join only when condition is met one time

There probably is a simple solution but I can't wrap my head around it. Let's say we have 4 tables persons (id, is_teacher) persons_relation (id, person_id, teacher_id) rooms_relation (id, person_id, room_id) rooms (id) (not used here) persons can…
lgs
  • 21
  • 1
2
votes
2 answers

Call to undefined method Illuminate\Database\Eloquent\Relations\BelongsTo::save()

I want to insert data into multiple tables (one to one), but i get error and in my database the column "metode_id" is null. i want the "metode_id" is not null this is class "Transaksi" : class Transaksi extends Model { protected $table =…
2
votes
2 answers

Is many tables an efficient database design for my purposes?

I need to create a database to store details about what regions game characters have been in and how they got there. I am planning to store the character UUID as a binary(16) index, the region name as varchar(25), and the unix time as an int; other…
2
votes
3 answers

Deleting from multiple tables using gridview delete command

I have a grid view utilizing sql data source. Now I want to delete a record using grid view's delete command, the problem is that a single record is based on information collected from multiple tables, so I have to delete parts of information from…
Ahmed
  • 645
  • 4
  • 13
  • 24
2
votes
1 answer

TSQL: How to get a UNION result from two tables with XML information in T1.Field_A and nvarchar in T2.Field_A

I have two separate data input tables from different sources (one direct insert, one via API). I´m trying to fetch a unified list of tuples out of these two tables using the UNION command. Unfortunately the information of the field SourceEventID has…
Foster80
  • 23
  • 3
2
votes
1 answer

Getting the Total Item Quanity from previous Transactions by Date of Transaction and Getting Current Item Quantity Total

I have 3 Tables Namely: Inventory: |ID|ItemID|TransactionDate |Item |Unit|Quantity| ---------------------------------------------------------------- |1 |1 |2019-07-10 12:23:51 |Plastic Cup 22oz |Pc |200 …
Matt Pedrosa
  • 87
  • 3
  • 10
2
votes
2 answers

Getting name from phone number from multiple tables?

i have this tables: inbox table SenderNumber Message contact table Name Number district table id SpvName Number sub_district table id district_id SpvName Number village table id sub_district_id SpvName Number i want to get name or spvname…
dieehard
  • 23
  • 3
2
votes
0 answers

Sum Numbers from multiple tables

I am working on a side project in order to further my background in PL/SQL. The project I am currently working on involves stats from a online video game - Madden 19. I am trying to sum/aggregate all of the stats into one view/table. For example, I…
2
votes
1 answer

Show combined result from unrelated tables (linq to sql)

I'm struggling to work out the best way to show a combined result from two unrelated tables using linq to sql (C#). The tables are EmailAlerts and TextAlerts, each with UserName, Type and Status (plus other columns that differ, but only need these…
annelie
  • 2,569
  • 6
  • 25
  • 39