Using MariaDB v. 10, I try to add a custom constant as the first column of my SELECT query, before all other columns *. This results in the generic syntax error 1064. For example: If I select only some columns, it works: And it also works if I use * to select all columns, but put my constant column after
Tag: mysql
Filtering by dates saved as strings in SQL [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago. Improve this question I’m developing a program in Java that saves medical information of e…
How to get one extra record for LEFT JOIN to represent a record not include on the left joined table
I have a database with two tables one table (shops) has an admin user column and the other a user with less privileges. I plan to LEFT JOIN the table of the user with less privileges. When I retrieve the data, the records for the admin user must be on a separate row and must have NULL values for the
SQL Subtract from different tables
I’m subtracting values from diferent tables based on ID. Its like an inventory where I’ve the tables for Itens In and Itens Out. What I want to do is to substract the Itens In – Itens Out based on ID …
MySQL DATEDIFF function VS compare INTERVAL DAY
What is the difference between DATEDIFF function and subtract INTERVAL DAY directly? SELECT * FROM table WHERE DATEDIFF(CURDATE(), publish_date) = …
Mysql how to select only row in same table and same identifier but different value
I have this dataset : UserPlans table : how to only select this row (with ID 3) since this data has been deleted but doesn’t have any data with deletedAt = NULL with same userId ? Answer You seem to want rows where userid has no other row whose deletedAt is null. If so, you can use not exists and
SQL SELECT from based on truth table
How can I select the columns to be returned by a lookup truth table? my data: | nam | X | Y | | Bob | 2 | 5 | | Jan | 1 | 6 | the lookup table | prop| SHOW | | nam | true | | X | false| | Y | …
Tables being queried with SQL and Sqlalchemy have same column names
I am querying a variety of different tables in a mysql database with sqlalchemy, and sql query code. My issue right now is renaming some of the columns being joined. The queries are all coming into …
Unable to create this MYSQL Trigger on PHPMYADMIN
I am trying to update a column ( called DateModified ) before update happens on the table row. so here is my trigger: CREATE TRIGGER `date_mod_category` BEFORE UPDATE ON `categories` FOR EACH ROW …
rowCount for items over 45 days old
I have a table and use this to show me how many days the widgets have been in stock, this is the code I am using for this I have info boxes at the top of the screen giving me different widget info, what I wanted is one of these info boxes to give me a total of how many