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
-1
votes
3 answers

MySQL: Select from multiple tables with field to show which table the record came from

I have 3 tables which contain very similar information. The tables are owners, managers, and employees. I am trying to pull information from all 3 tables, while still understanding which table each record came from. I also do not want duplicates.…
Chris
  • 4,762
  • 3
  • 44
  • 79
-1
votes
2 answers

MySQL Inner Join of 2 different tables on 2 different coloumns that are part of both said tables

Hello fellow programmers, to describe my problem a bit better: I've got 2 tables with a lot of columns. They have some of coloumns in common. Table 1 is the Customer table with Customer ID, First Name, Last Name, Company, Street, Zipcode, City,…
-1
votes
1 answer

SUM for Multiple Table and Child Table

I need to create JOIN syntax for this query in MySQL : SELECT TblSupplier.SupplierName AS SupplierName, (SUM(TblBuy.TotalBuy) - SUM(TblReturn.TotalReturn)) AS Total (SUM(TblPayment.TotalPaymentToday) -…
-1
votes
1 answer

retrieving data from two mysql tables where the second table depends on the first

I have two MySql tables: users(id_user, name, age, gender ). ways(#id_user,id_way, start, end, date). What I want is to retrieve all the ways with their corresponding users details. So my result would be like this: id_way | start | end …
-1
votes
2 answers

Multiple joins in multiple tables

i have the tables below: patient: id, incidentCode, name, insurance, contactdetailsID contactDetails: id, cityCode lookup: id, lookupdescription incident: id, date patient joins contactdetails like: inner join contactdetails on…
-1
votes
1 answer

EF - Multiple Primary Keys Linking Tables

We need a solution to the following problem which makes sense an also follows best practices without making things to complicated. We have 3 tables which need to be linked, Sector, Location and Company. ie: A Company "Bobs B&B" is in Sector…
Talon
  • 3,466
  • 3
  • 32
  • 47
-2
votes
1 answer

How can I nest multple tables into one while modifying them?

I have multiple tables which I need to merge into one after performing some operations into each one of them. A first nesting was achieved thanks to a (working) "WITH" statement: With T1 as (Select col1, col2, col3,... from *database* where…
-2
votes
1 answer

Is It possible to return Multiple tables from stored proc in MYSQL

I am want to return two tables from one Stored Proc. I am not sure if it is possible or not, but it is possible in MSSQL, so, I guess it is possible in MYSQL as well. What I want to achieve is: select * from table1; select * from table2; result in…
Ram Singh
  • 6,664
  • 35
  • 100
  • 166
-2
votes
1 answer

Make query from multiple tables shorter and optimized

I am using PreparedStatement in Java. I have a sql-query from multiple tables. If it's possible, how can i make this query much shorter and optimized? DB is "Oracle 12c database". Also my task is to make the query sql-injection safe and to prevent…
Vladimir
  • 3
  • 2
-2
votes
1 answer

Is there any ways to update multi collections at the same time in Mongodb

based on some system arch, i may need to update multiple collection under some name rule, e.g. [m_aaaa_info], [m_aaab_info] .etc thus i may need to update all the collections named by [m_*_info], with the same select & update conditions like…
-2
votes
1 answer

selecting multiple items form multiple tables with min and max

I'm having a little trouble figuring out this SQL statement. I have three tables employee, job, and job type. job type is reference table. It has the name of the job, how long that job takes, and how much is charged for that job. job has records of…
user2328273
  • 868
  • 3
  • 12
  • 22
-2
votes
1 answer

Insertion of data into multiple table using primary key and foreign key through html form with php procedual and mysql

I am new to complicated databases. I want to add supplier detail I the database, which has 3 tables with name product, supplier, and purchase invoice. product have an id(primary key), product_name, and supplier_name(foreign key) A supplier have a…
-2
votes
2 answers

Joining 3 tables based on common columns

I have four tables - tblBase, tblLookup, tblData and tblData2 tblBase +---------+----------+-----------+------------+ | Base_ID | Base_Num | Base_Type | Base_Date | +---------+----------+-----------+------------+ | 1 | 1234 | ABC |…
Shanka
  • 811
  • 1
  • 7
  • 16
-2
votes
1 answer

Sql query with 4 tables

I have 4 tables: Fonctionnaire, Echelon, PromotionEchelon, Mise. Fonctionnaire: CodeFonctionnaire(PK), NomFonctionnaire, PrenomFonctionnaire Echelon : NumEchelon(PK), CodeEchelon,…
user4340666
  • 1,453
  • 15
  • 36
-2
votes
2 answers

mySQL Queries through multiple tables

My first post here. I have an assignment to deliver in mysql and I have found a difficulty in 2 questions. First and foremost the tables of a database are the following: departments (dep_no, dep_name) dept_emp (emp_no, dept_no, from_date,…
1 2 3
54
55