I want to perform something like this Answer If I understand correctly, you want to conditionally join to a table. I would recommend two left joins as in: Because it is the same table, you could also use or in the on clause: However, or in an on clause usually kills performance.
Tag: mysql
replace column with other column if value is ABC*
MYSQL PHPmyAdmin I have a table “photo” I have a column named “column_title” (varchar(300)) and a column named “column_description” (text). The title is sometimes ABC and …
how parallel fetch data from MySQL with Sequel Pro in R
I want to fetch data from mysql with seqlpro in R but when I run the query it takes ages. here is my code : old_value
Incorrect number of arguments for PROCEDURE… from C#
I am having trouble using parameters in a stored procedure. I believe I am not passing the parameters in correctly with the C#. My code is roughly equivalent to: public static string GetCustomer(…
SQL: create global alias for nested SELECT to be used in another nested SELECT
Let’s assume I’ve got a database with two tables: people which contains person’s id and his/her birth year for each person and parents which contains the (parent_id, child_id) pairs to represent the relative relationships between people. To make the explanation easier let’s assume each…
Why this IF NOT EXISTS statement is not ok?
I’m trying to create a table but it keeps giving me error and I’m not able to figure out the problem even after checking the manual That’s the code: Answer I solved by using a different word from VALUE. It is already defined as keyword
get 2nd highest sum in mysql
i have table emp : emp_id quantity 1001 21 1001 10 1002 3 1002 5 1004 4 1004 5 1004 8 i want to get the id having 2nd highest sum so expected output is 1004 17 let me know how can …
Query returns duplicate values [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 1 year ago. Improve this question The query below is showing some duplicate and wrong values: The output should look like this:…
Using two single-column indexes in where and orderby clause
I have googled a lot and couldn’t find a clear answer to my question assume we have this query SELECT * WHERE user_id = x ORDER BY date_created If we have a single column index on user_id and another …
Query to list users who have answered similarly to questions as the specified user
I’m making a project in which users answer questions with yes/no choices and an option of must-match, e.g.: Question 1) Stack Overflow is helpful? [Yes / No] [MustMatch] Question 2) Hills are better than beaches? [Yes / No] [MustMatch] etc. Users can skip questions if they want. I need MySQL query to ca…