Skip to content

Tag: sql

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 da…

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…

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…

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…

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 …