Skip to content

Tag: select

Filtering empty rows from Mysql SELECT query issue

I have a SELECT query as below: This query gives me an output like this: My question is, how to filter the 0 due records from due_balance and modify the query to get the rest? Expecting result should be: I tried it in this way, but it doesn’t work for me. Answer Use HAVING Clause or use subquery then ad…

Getting not valid month in Oracle sql

I have a table called Transactions that has a column called trans_date. I am just trying to do a simple query in the SQL*Plus command window The query is When I run this query I get not valid month and there is a little * under trans_date. Most of what I have read suggests the query is right but I

SQL complicated SELECT query

I would like to have a select query, where I get all the games that a specific user played with the points of his and the opponents team. Entity relatioship model of my database This is my current query: The current query gives me this result: userId gameId won points 1 1 true 19 Problem: From this query I on…

MySQL procedure not working with both select and delete

I created a procedure to get a vehicle id from the vehicle table using vehicle number input, then delete the booking record for that vehicle id, and at last to delete the entry in the vehicle table… But when creating the procedure I get an error at line 7 saying Error Code: 1064. You have an error in yo…

sqlite3 INSERT INTO UNION SELECT

Table columns: pk is the auto-incrementing primary key An error occurs when I execute this SQL DB Error: 1 “table table1 has 4 columns but 3 values were supplied” Answer You should explicitly specify which columns in table1 your insert is targeting: When you omit the select list entirely, SQLite w…