Questions tagged [right-join]

The RIGHT JOIN keyword will return all the rows from the right table, even if there are no matches in the left table.

SQL RIGHT JOIN ON returns the rows of INNER JOIN ON plus unmatched right table rows extended by NULLs. A consequence is that it returns all the rows from the right table at least once even if there are no matches in the left table. See examples here.

233 questions
1
vote
2 answers

MySQL right join slow performance

I have two tables: Restaurants and SurveyInvitation. One restaurants has many survey invitation. I want to select all the restaurants that have a survey invitation and the status of it is 'approved', 'completed', 'hidden_review' . The restaurants…
Fox Alex
  • 133
  • 2
  • 9
1
vote
2 answers

Join with Multiple Tables

I am getting a syntax error with the following problem and can't seem to figure out, hope you guys can help me! I have these tables (they are populated): I am trying to retrieve the first and last name of all the passengers scheduled in a certain…
SPedraza
  • 159
  • 2
  • 2
  • 10
1
vote
1 answer

Right join multiple key where mutiple key is null

I need help from captain obvious I suppose. I'm trying to Insert data from a table into a temptable. Ok this is easy I need to insert the data we got today and the data we got 10 days ago. The where clause may aford it, th's okay What for me is hard…
Valentin C
  • 161
  • 1
  • 7
1
vote
1 answer

percent match within the same table

Below I have an MySQL database where "id" is just an id for each row. "question" shows the id of the question. There are four questions, 11, 12, 13 and 14. For every question the user has four answer options (1,2,3 and 4) which is stored in the…
Joey_D
  • 117
  • 1
  • 7
1
vote
2 answers

select parent whether it has child or not in mysql

I need to select all users whether they have images or not If they have then select the primary image. It could be simple for you but looking difficult for me. I have 2 tables users , images Users Table Id | name | 1 xyz 2 abc 3 …
learner
  • 171
  • 2
  • 11
1
vote
1 answer

MySQL Left Join Right Join union returns incorrect data

My classmates and I have been run rampant trying to get this query to work correctly. Goal: Return a single table that consists of two tables fully joined by means of a left join and then a right join. There will be null values. The purpose of this…
bjfrees
  • 45
  • 4
1
vote
1 answer

Table A Left Outer JOIN Table B VS Table B Right Outer JOIN A

Is TABLE A LEFT OUTER JOIN TABLE B the same as TABLE B RIGHT OUTER JOIN TABLE A in in terms of output and performance? (Regardless of data content and size of table A, and table B)
user2845337
  • 43
  • 1
  • 4
1
vote
1 answer

Right join query in symfony3 with doctrine

I want to convert the sql query below to doctrine query in symfony. select p.name,p.id,sum(t.amount) as bal from transactions t right join processors p on t.processor_id=p.id where user_id=18 or user_id is null group by p.id The above code fetches…
AllexOne
  • 13
  • 4
1
vote
1 answer

Oracle ROWNUM with multiple joins

I'm trying to execute a query on an Oracle database. My table structure is: d--o one-to-one o--r one-to-many o--m many-to-many (via mtm) I'm using the following query: SELECT o.id ID, ROWNUM rn /*row…
Jakabfi Attila
  • 367
  • 3
  • 16
1
vote
1 answer

INNER, OUTER OR RIGHT JOIN with 3 tables where one has same PK as the joining one but 1st doesn't

Hello I am currently trying to combine, 3 types of tables. I have mange to do it with 2 that have same values but what happends when you want the a 3rd table that has same pk as second but not first? And I hit a giant brick wall.... how do I solve…
MikeBroski
  • 64
  • 1
  • 8
1
vote
1 answer

In Mysql, Left/right join gets result same column twice

I have a very basic problem in mySQL query. My code is that select * from member left join cupwinner on member.mid=cupwinner.mid; As a result, my final table has twice "mid" column. Table has these columns: MID, name, Mtype, Debt, MID, Year,…
MMT
  • 27
  • 1
  • 5
1
vote
0 answers

how can I "order by" join sql query?

This works... $sql30 = "SELECT * FROM statuses LEFT JOIN friends ON statuses.userID=friends.lowerFriendID WHERE friends.lowerFriendID != :user_ida UNION SELECT * FROM statuses RIGHT JOIN friends ON statuses.userID=friends.higherFriendID WHERE…
Donald
  • 35
  • 1
  • 5
1
vote
3 answers

MySQL Left Join behaving like Inner Join

Here is my query: SELECT logins.user as user, rozliczenia.godziny as godziny, rozliczenia.stawka as stawka, rozliczenia.premia as premia, rozliczenia.premiainna as premiainna FROM logins LEFT JOIN…
user5306544
1
vote
1 answer

Right Join to CTE_dates not returning all dates

Long time lurker but first time posting; I can't for the life of me work this out on my own, or find an answer anywhere that solves this. I have table1 with columns department, sales, date. Each row records a sale. I want a query to return the last…
1
vote
2 answers

How to find LEFT OUTER JOIN or RIGHT OUTER JOIN with ORACLE JOIN (+)

I am confused with finding left outer join and right outer join properly with Oracle join (+) sign. Check this vs this. I feel both contradict. What I understand is, First link says if the (+) sign is in right hand side, it will be Right Outer…
ever alian
  • 1,028
  • 3
  • 15
  • 45