I have a Relationships table that looks something like this And 2 tables From and To I’m trying to update the JsonPair column with Json objects in the form {FromName: ToName}. So the resulting table would look like I’m a novice at SQL. I’m thinking that I should SELECT the names first, then …
Tag: mysql
Why am I getting a duplicated column when doing this SQL query?
I am trying to do a set of queries in mySQL. In my final query I am trying to select the course_id column, but there are two columns with the title course_id and the exact same values, so I am encountering an error saying Query Error: Error: ER_NON_UNIQ_ERROR: Column ‘course_id’ in field list is a…
Will I need to do a join of 4 tables to fulfill this SQL query or is there a simpler method?
I currently need to do the following: Find the names of all course and the students enrolled on them which take place on a Friday afternoon and have at least 2 students enrolled on it. I am thinking what I should do is Join the tables titled student, takes, course, section and time_slot together and from ther…
How to fetch all values of a column based on value of another column in same table?
I got the following structure: How to fetch all values by taking the $_SESSION[‘admin’][‘id’], finding the country_id of that admin and getting all other admin_id and country_id that are the same of the session admin? So, lets say the currently logged in admin has id = 5 , that means t…
How to find a non-existing value from another table in mysql using ONE single QUERY
I want to find number of types of produce of each farmer, names of farmer and the total number of produces but I am getting stuck in the part trying to display farmers who do not produce anything in the supplies and then in another query I want to extend it to display farmers with highest produces but without…
How to prevent MySql Injection in dynamic where?
I have an API in my C# WEBApi project which return some items from my MySQL DB. The data to return has a visibility set in a table and the params set in the API call says which kind of data should be …
SQL Complex update query filter distinct values only
I have 3 tables with following columns. Table: A with column: newColumnTyp1, typ2 Table: B with column: typ2, tableC_id_fk Table: C with column: id, typ1 I wanted to update values in A.newColumnTyp1 …
SQL phpmyadmin SELECT and return multiple fields as string concat in a column of parent SELECT
I have 3 tables. users, contents and categories. so a user writes a content and selects a category for that. categories users ————————– ——————–…
Mysql SQL syntax group by [asc|desc]?
In using mysql8.0 it gives the GROUP BY syntax as the following: [GROUP BY {col_name | expr | position} [ASC | DESC], … [WITH ROLLUP]] What is the usage of the asc or desc in the group by? Every …
How do I remove results based on conditions to calculate an average
I have the schema below. A quick explanation of it is: bob rated up 5/5 james rated up 1/5 macy rated up 5/5 The logic: If I am personA, look up everyone I have blocked. Look up all the movie …