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 da…
Tag: sql
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: sho…
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…
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 g…
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 …
How can I append a string to an existing field in MySQL?
I want to update the code on all my record to what they currently are plus _standard any ideas? So for example if the codes are apple_1 and apple_2 I need them to be apple_1_standard and apple_2_standard Before: Psuedo Query: Expected result: Answer You need to use the CONCAT() function in MySQL for string co…
Boolean vs tinyint(1) for boolean values in MySQL
What column type is best to use in a MySQL database for boolean values? I use boolean but my colleague uses tinyint(1). Answer These data types are synonyms.
Mysql Complex Where Clause
I really surprised when I tried below code in MySQL: It doesn’t work. I need to get product that is both free_shipping is ‘yes’ AND price equal ‘5’ at the same time. How can I create this query properly? Table Structure: contents: (TABLE 1) content_fields: (TABLE 2) Example (Get …