Skip to content

Tag: join

Generate random pairs SQL

Suppose we have these two tables. TABLE1: TABLE_2: I want to pair all rows of TABLE_1 with some random columns from TABLE_2 where each pair is gonna have a random amount of distinct rows from TABLE_2 (range 1,2,3) An output could be: Answer did the thing for me.

Making a MySQL COUNT query

after 4 days of tries and researchs over the web I can’t make my wishes working. Any help would be appreciated ! Performed on MYSQL WORKBENCH I got a DB made of 3 tables : user Posts likes username id id id title userId (foreign key from user.id) email content postId (foreign key from posts.id) password…

left join on the first appeared row by datetime

If classes ‘Math’ or ‘Biology’ have flag is NULL or = 0, we need to left join with the first appeared (according to the date) classes ‘Literature’ or ‘English Literature’ from the below. If classes ‘Math’ or ‘Biology’ have flag = 1 then w…

How to delete rows that have duplicate column combination

I need to delete some rows that have the same column combination (except ID). The row that should be kept is the one that has the maximum reference date So, after the query the table should be like this I know that the query below will return the table I want, but I don’t know how to delete the “d…

Join same two tables multiple times in one query [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last month. Improve this question I have problem with my query and i can not figure it how to do it. What i want to do is to di…

show who resit and passed and what course was it?

i need help find who fail in exam & resit and pass the exam only, heres the code: heres the result: I need find like this: Answer Possibly using a query like below. this is using your query as input. Also we have assumed that it is not possible to have a student have (PASS, FAIL) for a student on