I have got a table which has an id (primary key with auto increment), uid (key refering to users id for example) and something else which for my question won’t matter. I want to make, lets call it, different auto-increment keys on id for each uid entry. So, I will add an entry with uid 10, and the id field
Tag: sql
Doctrine 2 Query Builder abs Function
This Work: This Don’t Work: The Error: Syntax Error] line 0, col 118: Error: Expected end of string, got ‘(‘ The native doctrine function abs work only on a select part of statment and don’t work on order by part. Obs: 1-) Im avoiding to use NativeQuery. 2-) u.code is a varchar fild on mysql and need to be varchar
How do I add a custom CHECK constraint on a MySQL table?
I am having trouble with this table I want to have a foreign key constraint, and that works. Then, I also want to add a constraint to the attribute status so it can only take the values ‘a’, ‘d’ and ‘u’. It is not possible for me to set the field as Enum or set. Can anyone tell me why
Bulk load data conversion error (truncation)
I am getting this error Bulk load data conversion error (truncation) for row 1, column 12 (is_download) here is the csv…it only has one row 30,Bill,Worthy,sales,,709888499,bat@bat.com,,”Im a a …
Create SQL INSERT Script with values gathered from table
I need to create a INSERT script in order to insert in another database the same data. If in SQL Server I select “Script table as > INSERT To” I can easily recreate the skeleton for the INSERT …
What are the pros and cons of performing calculations in sql vs. in your application
shopkeeper table has following fields: Let’s say, I have the above table. I want to get the records for yesterday and generate a report by having the amount printed to cents. One way of doing is to perform calculations in my java application and execute a simple query and then loop through the records and convert amount to cents in
Cannot insert the value NULL into column
I’m having some problems. I am trying to get a table to update, however it is not updating because one of the fields contains rows with a NULL value. Heres the original query which gives no error: Now, the nextUpdate column might be NULL, so I am trying to accommodate for that with this query: You can see I’ve added
How to get the employees with their managers
This is what I want the output to look like: Employee Emp# Manager Mgr# BLAKE 7698 KING 7839 CLARK 7782 KING 7839 JONES 7566 KING 7839 MARTIN 7654 BLAKE 7698 …
How to get second-highest salary employees in a table
It’s a question I got this afternoon: There a table contains ID, Name, and Salary of Employees, get names of the second-highest salary employees, in SQL Server Here’s my answer, I just wrote it in …
What does SQL clause “GROUP BY 1” mean?
Someone sent me a SQL query where the GROUP BY clause consisted of the statement: GROUP BY 1. This must be a typo right? No column is given the alias 1. What could this mean? Am I right to assume …