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
0
votes
1 answer

Is it possible to query two access tables where you want to know if a value/range in the first table is between two fields in the second table?

I'm trying to query two tables, ASSAYS, AND LITHO in a diamond drillhole database. I was given values (SAMPLE_NO) to search for in the ASSAYS table, to return values such as HOLE-ID, FROM, and TO. So each sample that we take has a HOLE-ID,…
0
votes
1 answer

Updating multiple tables using SqlDataAdapter

I've been trawling through pages and pages on the internet for days now trying different approaches and I'm still not sure how I should be doing this. On my third InsertCommand, I'd like to reference a column on the other 2 tables. // Populate a…
Robula
  • 649
  • 1
  • 12
  • 29
0
votes
2 answers

Return zero or null when Joining 3 tables in mysql

I am trying to JOIN 3 Tables(table1, table2 & table3) in Mysql query where I want to pull the matching data from 2 tables(table1 & table2) comparing a Common Column existing in 3 tables(ie. 'PID'). When Joining these 3 tables, there is no data in…
0
votes
3 answers

SELECT FROM view1, view2 when data available (JOIN?)

I'm not a SQL guy, and I've just tried every JOIN MySQL offers. I primarily need data from view1 using WHERE, ORDER BY, LIMIT with offset (the data is incorrect without those conditions.) view1 is not limited by view2 Data also needs to be pulled…
user1382306
0
votes
2 answers

Invalid argument supplied for foreach() in codeigniter (tiara)

i get error in the CI view page, as Invalid argument supplied for foreach(). this is my code : my database: (table of Penyewa) **id_penyewa nama_penyewa alamat …
0
votes
2 answers

SQL Join Against a Table Twice, Once With Foreign Key Match, Then With Non Match

I have the following table structure: table: user user_id | join_date 101 | '2012-4-13' 102 | '2012-6-4' 103 | NULL 104 | NULL table: job job_id | user_id 20 | 101 21 | 103 I want to return a single…
Adam Levitt
  • 10,316
  • 26
  • 84
  • 145
0
votes
3 answers

Using WHERE in a multiple query

This is based on a search engine I am receiving duplicate search results from this... $construct ="SELECT * FROM Rating, Attraction WHERE $construct" ; Then I was informed that it was selecting all results and rows and therefore repeating it so i…
0
votes
2 answers

Ordering fields by datetime from two tables

I have two tables (IncomingDocs) and (OutgoingDocs) each have a field called SubmitDate (datatype Datetime) and DepositNo (datatype Int) Each DeposotNo may have multiple Submitdate in a single table. For example; _IncomingDocs…
Arwa A
  • 259
  • 2
  • 5
  • 11
0
votes
2 answers

Android SQLite multiple table input

I have a budget program that uses multiple tables to store information. When I try to add information to more than 1 table at a time, I end up only having the first table receive any information. This is the code I use: public SQLiteDatabase…
0
votes
1 answer

CREATE Sql Server VIEW from multiple tables GROUPing BY, SELECTing subqueries AS aliases

Building on this post: MS Version of This MySQL View with GROUP BY? How can subqueries be added? All I want is to add to that view is an alias from a SELECT as an alias like: ... AS table2column2, (SELECT column1 FROM dbo.table3 WHERE constant = 1)…
user1382306
0
votes
1 answer

MS Version of This MySQL View with GROUP BY?

I was shown the ease that one can make a view from multiple tables, GROUPing BY an id of one of the tables in xception's awesome answer here: CREATE VIEW WHERE SELECTid = VIEWrowID Is there any way to do that in MS? Everywhere, I've read says "no",…
user1382306
0
votes
2 answers

Complex Select Query with multiple conditions and orders

SELECT p.* FROM Products p LEFT JOIN offertran ot ON p.prod_id = ot.prod_id LEFT JOIN Offers o ON ot.offer_id = o.id AND o.dF<=3 AND o.dt>=3 ORDER BY o.id DESC, p.prod_id ASC LIMIT 20 Please check the output in…
Anusha
  • 175
  • 3
  • 20
0
votes
1 answer

Comparing two rows each from two tables in MySQL, displaying only negative results

So I've got a table called "HoldingQueue" and I want to compare two rows to two values and return every row that doesn't match BOTH of those values. Here's an example of the content: * * * * * * * * * * * * * ItemCode * Channel * * * * * * * * * *…
rwhit85
  • 37
  • 4
0
votes
1 answer

Foreign Key Constraints may cause cycles or multiple cascade paths

Possible Duplicate: Foreign key constraint may cause cycles or multiple cascade paths? I am getting the following error while creating the table listed below. Msg 1785, Level 16, State 0, Line 1 Introducing FOREIGN KEY constraint…
Bryon
  • 1
  • 1
  • 2
0
votes
2 answers

Getting data from 2 related and 1 unrelated MySQL tables with one query?

I am trying to create an archives page for my blog, which is also still being built. I have three different MySQL tables I need to pull data from and 1 of them is unrelated from the other 2. I found a similar post here but seeing as how I am not…
Ty Bailey
  • 2,392
  • 11
  • 46
  • 79