Skip to content

Tag: sql

SQL: Return only first occurrence

I seldomly use SQL and I cannot find anything similar in my archive so I’m asking this simple query question: I need a query which one returns personID and only the first seenTime Records: Wanted result: That’s what I did & failed: P.S: Notice SQL CE 4 Answer If your seenTime increases as seen…

Rename a constraint in SQL Server?

Is it possible to rename a constraint in SQL Server? I don’t want to have to delete and create a new one because this constraint affects other already existing constraints and I will have to recreate/alter those. Answer You can rename using sp_rename using @objtype = ‘OBJECT’ This works on o…

Difference between natural join and inner join

What is the difference between a natural join and an inner join? Answer One significant difference between INNER JOIN and NATURAL JOIN is the number of columns returned. Consider: The INNER JOIN of TableA and TableB on Column1 will return The NATURAL JOIN of TableA and TableB on Column1 will return: The repea…

Exit the SQLite shell on Android

I’m using SQLite 3 on Mac OS X’s ADB shell to view my application database using: After I wrongly typed the quit command above, instead of the .quit for example, the shell goes into the …> prompt where none of the known commands seem to work. I can’t even get out by Ctrl + C, Ctrl +…

Multiple LEFT JOIN in Access

I have the following query, which works for MySQL: But it doesn’t work for MS Access. I’ve tried to add parentheses around the LEFT JOIN, but it gives me syntax error in FROM clause. So how should this query look in order to work in MS Access? Answer The Access DELETE requires a star (*): DELETE *…