I am trying to find the solution for the below query: There are declared tables @Country and @WHO (World Health Organization). Insert all possibles countries from table @Country into table @WHO. …
Tag: select
How to select by two fields using IN operator
I tried query like SELECT id FROM events WHERE iid = 2 AND target_id = 3 OR iid = 3 AND target_id = 5 OR… How to short this? Also tried to use IN operator but it get wrong logic SELECT id FROM …
How could I use case within join and union?
I have 2 tables: Matches Rounds Inserts My query: I would like to know what places a particular team achieved (should probably use HAVING m.matchwinner = ‘fnatic’) MatchID – Team – Place 1 – fnatic – 1st 3 – fnatic – 3rd 4 – fnatic – 3rd what places all teams achieved MatchID – Team – Place 1 – fnatic
How to insert into a row, a value from other table?
I have 3 Mysql tables. A table with the classes and the labs and their id. A table with the teachers_list and their subject. A table which is going to be the schedule.** I want to randomly assign one of the physicists to one of the physics labs on my third table which is going to be the schedule. **This
How to query for city name as well as length of the smallest city name from the same table
My code is this but gives error, don’t know why. Please help! Answer If you just want the city with the shortest name, you can simply order by and limit: This returns just one row. On the other hand, if you want to allow bottom ties, then you can filter with a subquery, like so:
Replacing null based on a condition
I am having a table with many columns (but posting only col1, col2, col3 here for simplified post): I want to fill null values of source _id with values from id. For example, source_id a5 row has null which has to replaced with id a1 values, subsequently, source_id a6 row having null to be replaced with a5 row Output: Answer
SQL query cannot use NOT LIKE to get results
I am starting out in SQL and am trying to do a query that will select all event names that are unique and do not have ‘TODAY-XXXXXXXX’ in the value for the event_name column. I have a query that works …
SQL’s union default order by clause?
I noticed when I am combining two tables via union that the order is not what I expected. calculus_class stats_class When I combine the two tables above I expect the results to be in order from top to bottom like this: This is the result I received using DBeaver PostgreSQL: Answer Actually, you are using union which removes duplicates, but
SQL not returning values where null in another table
I’m trying to use the SQL join function to grab information from multiple tables. My issue is I can’t seem to get the desired result. select a.DRINKER, sum(C.PRICE) from DRINKERS a …
MySQL join another table value based on 2 different tables matching value? [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 2 years ago. Improve this question The intended result is 12(price) and pic.png(profilepic). Is this possible to join jobs and profile based on the matching job_id’s (jobs+offers), which have matching user