Skip to content

Tag: mysql

Query Optimization in SQL in given case

These are the given tables: Question is: Write a optimized query to find out the name of all the customerIDs who ordered coffee that originated from ‘Costa Rica’ or ‘Indonesia’. My attempt: My teacher says it can be optimized more but I don’t see any way. Please Help me out. Answer Rather than these nes…

How to get the size of the duplicates in this query?

Let’s say I have the following data: I want to find out how much data I have in duplicates — that is — if we have one of each of the files (unique by md5) how much space do we save? The answer should be: Here is the base query I have thus far: I think the simplest way to

How to exclude certain entries from a query [SQL]

I do have the following issue: Let’s say you have a table that looks like this: Question: I want to have an query which will deliver all the NotPrimID’s which do have the Number as 13, however if the Number of a NotPrimID is also 14 etc. it should be automatically excluded from the list. Answer Yo…

MySQL Join Over 5 tables

The Situation We have these 5 different MySQL tables: Table club Id | ClubName | CityId —+———-+——– 1 | Test | 1 Table city Id | CityName | CountryId —+———-+———– 1 | …

Remove null values in MySQL and combine non null values into one cell

Hello guys? I have a MySQL table storing timetable classes, a specific subject is allocated to a specific timeslot stored in columns. I have no issue when there are no two subjects taught at the same time since I use max() to select from the time table i.e The above query gives me this results Now from the fi…