I have a table passenger_count pas1_id pas2_id count 1 6 2 14 37 4 that connects by pas_id with another table passenger: id name 1 Bruce k 2 George L 3 Li Wo 4 Don Wa How to replace pas1_id, pas2_id with actual names from passenger table? This self join query does not work: Answer Just join passenger to passe…
Tag: mysql
Out of Range Error while inserting into a MySQL decimal column
I have this tabular structure: I get an error when i try to insert a specific set of value, query with those values is as below: For longitude with value -161.9722021 it is throwing me an error, values less than 100 value were successfully inserted. I don’t see the value being out of range, the value i …
A query for getting results separated by a date gap
ID TIMESTAMP 1 2020-01-01 12:00:00 2 2020-02-01 12:00:00 3 2020-05-01 12:00:00 4 2020-06-01 12:00:00 5 2020-07-01 12:00:00 I am looking for a way to get records in a MySQL database that are …
Inner Join returned values
I have a query such as, select name from employee inner join task on employee.id = task.employee_id order by name asc Tables look like: employee id name 1 Emily 2 Sam 3 AI 4 Joe 5 …
fetch records based on mysql alias using having clause
i am having bibles table where user read 3 bible chapters every day. My query works fine as from this answer . i have two columns in table id, chapter_name i.e below :- and after that i used below query Its giving me blow output :- what i want when user requests for date 24 feb 2020 it must come
how do i rewrite the correct statement for COUNT under this condition
Bring back the count of all the batsmen who have played a certain number of innings only if there are more than one batsman who have played that number of innings. 4 innings – 2 batsmen, 5 innings – 3 batsmen etc. Player is the field name for the batsmens name. I am kinda stuck on how to write the
SQL filter out string that matches condition and with specific exception to pass
Sample data I wanted to filter out all the data that contains test with the exception of one My expected return result is: I can code this in PHP like this. Or in JavaScript like this But I need it in SQL Answer I can see that in your PHP/Js code you’re defining two condition; any value that have ‘…
How to short a sql case query that uses between
Hi have this sql query: How can I short this query so I don’t use a lot of case statements? Answer You can try using mod subtracting the remainder t from you value by division for 1000 or as suggested by @DM you can also use the difference should be the same .. both involve function .. but there are
how to choose value in 1 column that must have 2 values in another – sql?
table: the id 11 has both taught in classroom 11A, 11B. How to select the ids that have both values 11a,11b? I tried this with no luck: because it gives empty table, because it can’t be both 11a and b at the same time. Answer If it’s exectly two values you can make an inner join
get the scheduling data based on 3 years in mysql
I have one table bibles that having two columns only i.e. is below:- Bible Scheduling starts from 5 sept 2021 for 3 years and ends on 31 Aug 2024 i.e basically bible repeats three time in 3 years. Now Suppose today date is 8 Sept 2021 So now requested date is 8 spet 2021 i want to fetch the 4th