Someone sent me a SQL query where the GROUP BY clause consisted of the statement: GROUP BY 1. This must be a typo right? No column is given the alias 1. What could this mean? Am I right to assume …
Tag: mysql
SQL: How to get the count of each distinct value in a column?
I have a SQL table called “posts” that looks like this: id | category ———————– 1 | 3 2 | 1 3 | 4 4 | 2 5 | 1 6 | 1 7 | 2 Each category number corresponds to a category. How …
SQL calculating time between assignments
I have to write an SQL statement which contain a field that contain two different values consecutively but in the way I have wrote it, it return always null because it is interpreted as having the two value in the same time! My conditions should be : (ci.field = ‘Group’ and ci.oldString = ‘Triage’ ) and (ci.field=’assignee’ and ci.newString is
Storing IPv6 Addresses in MySQL
As has been requested in “ipv6-capable inet_aton and inet_ntoa functions needed”, there is currently no MySQL function for storing IPv6 addresses. What would be the recommended data type/function for …
MySQL – specific columns on join?
When making a join (inner, left outer, right outer or whatever), how can I specify which columns on the table to join into the original table? Consider the following example: This would select FirstName from user, but select everything from Provider. How can I specify which parts of Provider should be included in the resultset? Answer This will only include
SQL Query to get column values that correspond with MAX value of another column?
Ok, this is my query: When it pulls the data, I get the correct row for the video_id, but it pulls the first row for each category for the others. So when I get the max result for the video_id of category 1, I get the max ID, but the first row in the table for the url, date, title,
How to select date and time without the seconds in mysql?
How do I select date and time without the seconds in mysql from a column with date value in a table ? “YYYY-MM-DD HH:MM:SS” should be “YYYY-MM-DD HH:MM” Answer
How to write query for this?
Hi friends I have a table like this ID bid sub_bid cid sub_cid 1 0 2 1 0 2 5 0 3 0 3 3 0 0 4 4 2 0 4 0 on that table either (bid or sub_bid) OR (cid or sub_cid) will be null. I have to write a query for fetching like this.. if bid is
How to write condition wise result providing query?
I want to write a MySQL query that gives a condition wise result. For example. I have a table with question, answer value, user chose value fields. User can attend to answer that question many times. qid rightanz wronganz 11 4 2 11 4 4 11 4 1 25 1 1 I want out put like this qid rightanz wronganz
‘LIKE (‘%this%’ OR ‘%that%’) and something=else’ not working
I have a select query where I am trying to search strings for multiple patterns Returns zero results However returns results and returns result Is it possible to get all my results into one query? If a string matches both, how will it handle that? Answer It would be nice if you could, but you can’t use that syntax in