I have a Jobs and a Companies table, and I want to extract 20 jobs that meet the following criteria: Jobs only from two (2) named companies There can at most be 10 jobs per company I have tried the following SELECT with UNION DISTINCT, but the problem is that the LIMIT 0,10 applies to the whole result set. I
Selecting a single row in MySQL
I am using MySQL, I have a table that has 9 columns. One of them is the primary key. How can I select a single row, by the primary key or column 8 or 4? Answer If I understand your question correctly: The ‘LIMIT’ keyword makes sure there is only one row returned.
Finding the next available id in MySQL
I have to find the next available id (if there are 5 data in database, I have to get the next available insert place which is 6) in a MySQL database. How can I do that? I have used MAX(id), but when …
Why & When should I use SPARSE COLUMN? (SQL SERVER 2008)
After going thru some tutorials on SQL Server 2008’s new feature “SPARSE COLUMN”, I have found that it doesn’t take any space if the column value is 0 or NULL but when there is a value, it takes 4 …
Best table design for application configuration or application option settings?
I need to store a series of configuration values in a database. A couple ways I thought of to store them are: a table with 2 colums(name,value) and a row for each pair, or a table with a column for each config parameter and 1 row? With the first I only need to add another row to add a config
How do I ‘subtract’ sql tables?
Its not really a subtraction I’m looking for. And I know its not a union or intersection… I have been given a long and complex stored procedure that returns a table of active and inactive documents. I have also been given a similar stored procedure that returns another table that contains only the active documents. How could I get a
How can I declare a Boolean parameter in SQL statement?
How can I declare a Boolean parameter in SQL statement? Answer The same way you declare any other variable, just use the bit type: Note this is semantically different from a true boolean. The 1/0 values won’t always just map to true/false the way you might expect.
What does DELIMITER // do in a Trigger?
DELIMITER // What is the of use of it?
Unknown column in ‘field list’ error on MySQL Update query
I keep getting MySQL error #1054, when trying to perform this update query: It’s probably some syntax error, but I’ve tried using an inner join instead and other alterations, but I keep getting the same message: Answer Try using different quotes for “y” as the identifier quote character is the backtick (`). Otherwise MySQL “thinks” that you point to a
SQL, How to Concatenate results?
I currently have a SQL query that returns a number of fields. I need one f the fields to be effectively a sub query sub that. The Problem in detail: If I have a table X with two columns, ModuleID and say ModuleValue, how can I write a SQL query to take the results and Concatenate it into one field: