Assuming that I have two tables, names and phones, and I want to insert data from some input to the tables, in one query. How can it be done?
SQL statement to get all customers with no orders
I have a typical Persons table and an Orders table defined in such a way that I can do JOIN query as the following to return Orders for all Persons. The question is, how do I write a statement that would return all Persons with NO Orders? I’m using mysql. Thank all in advance. Answer You may want to use
Convert INT to DATETIME (SQL)
I am trying to convert a date to datetime but am getting errors. The datatype I’m converting from is (float,null) and I’d like to convert it to DATETIME. The first line of this code works fine, but I get this error on the second line: Arithmetic overflow error converting expression to data type datetime. Answer you need to convert to
SQL query to find Nth highest salary from a salary table
How can I find the Nth highest salary in a table containing salaries in SQL Server?
Ideal database for geo (map) data
I’m looking for suggestions for an ideal database or data structure for storing a map. Essentially, the map consists of “ways” which are like roads, paths, etc. Ways contain nodes (which have a latitude and longitude coordinate, and sometimes an altitude.) Any such database or structure: should be able to locate all the nodes in a bounding box quickly (milliseconds)
Getting result of dynamic SQL into a variable for sql-server
Executing dynamic SQL as follows in Stored Procedure: How do I use the count(*) column value as return value in the SP? Answer
Use email address as primary key?
Is email address a bad candidate for primary when compared to auto incrementing numbers? Our web application needs the email address to be unique in the system. So, I thought of using email address …
SQL query for multiple tag inclusion
I´m net very good in explaining this. But i do my best: I’ve made a tagging tool for people. Some people contains more then 1 tag, and i need to get those but dont know how to write the SQL query for multiple tag inclusion. I know you can’t write WHERE conditions like this: LOWER( peoples_tags.tag_id ) = ‘outside’ AND
Count number of users from a certain country
I have a table of users, and in this table I have a country field telling where these people are from (i.e. “Sweden”, “Italy”, …). How can I do a SQL query to get something like: Users select their countries from a list I give to them, but the list is really huge so it would be great to have
COUNT results from SQL Query with a HAVING clause
Are you able to use COUNT in a query with a HAVING clause so that the COUNT returns the number of rows? When I try, Im getting the count of the number of times the ID shows up in the table. Here is …