An SQL join clause combines records from two or more tables or views.

learn more… | top users | synonyms

2
votes
1answer
63 views

Best practice: Unions or a derived table?

I've inherited a medium-sized database with a terrible schema. The sanitized portion in question is like so: CREATE TABLE `pending` ( ... `invoice` int(11) DEFAULT NULL, `lid` int(11) DEFAULT ...
0
votes
1answer
58 views

Complicated join with where clause

I have four tables: sales sales_thumbs sales_images sales_sizes sales table: +--------------+---------------------+------+-----+---------+----------------+ | Field | Type | ...
2
votes
0answers
46 views

update statement with self join

I needed to copy information from one row of a table to another. I noticed I could do the following: update address set col1 = a2.col1, col2 = a2.col2, .....etc from address a1, address a2 where ...
1
vote
0answers
29 views

parenthetic grouping of join clauses

What is the difference between these joins? a left join b left join c (a left join b) left join c a left join (b left join c) Does the grouping only affect the order of the joins? Will the query ...
1
vote
0answers
58 views

How can I join one to one to (many to one) without using group_concat

I have a table structure as follows: -- -- Table structure for table `emails` -- CREATE TABLE IF NOT EXISTS `emails` ( `ID` int(5) NOT NULL AUTO_INCREMENT, `email` varchar(255) COLLATE ...
1
vote
0answers
320 views

MySQL join for multiple child records in a single joined row

I have one master table (teacher) structured like teacherId Name Class 1 Praveen 10 2 John 9 and having a child table (student) structured like studentId ...
1
vote
0answers
133 views

Multi-Table Join to Single Destination

I am having a serious performance issue with join together four tables and placing the results (in a certain permutation) into one destination table. I am using MSSQL 2008 and good ole T-SQL. To ...
0
votes
0answers
25 views

Missing values in INNER JOIN MS-Access?

When I run the following query in MS-Access: SELECT a1.ConStateNumber, a2.ConStateNumber FROM qryW2_yr_sum_slash_qryW2_q4_sum_result a1 INNER JOIN qryW2_q3_sum a2 ON a1.ConStateNumber = ...
0
votes
0answers
42 views

one vs two column index difference when doing JOIN query?

Let`s suppose that alfa,beta and gamma contains milions of rows so we need to create indexes obviously to get optimal performace for this query : SELECT * FROM alfa JOIN beta on beta.id = ...
0
votes
0answers
32 views

How Can I do and INNER JOIN USING (2 columns)?

Suppose we have: CREATE TABLE cscart_products_prices_temp LIKE cscart_products_prices; ALTER TABLE `cscart_products_prices_temp` DROP `percentage_discount`, DROP `lower_limit`, LOAD DATA LOCAL ...
0
votes
0answers
64 views

How can I get multiple rows instead of columns after self-joins?

This is my situation (the real table isn't about people but about paths): [Table: People] id | name | type | related_to ---------------------------- 1 | | | 0 2 | Nico | Friend | ...
0
votes
0answers
111 views

Which update is faster using join or sequential?

My this question is in sequence of my previous question I asked. I could write two solutions using Stored Procedure instead of trigger or nested-query . Both use a helper function ...