Skip to content
Advertisement

Tag: mysql

MySQL put a specific row at the top of the result

I’m doing a basic SQL select query which returns a set of results. I want a specific row which the entry “Fee” to be put at the top of the results, then the rest. Something like: Can anyone help? Answer You could try this :

Using 2 “Group By” in one SQL Query

I got 3 tables that look like this: Locations: id,name Events: id,name,locationid Participants: id,name,eventid What I want is a query, that returns all locations, a count of the events linked to it and a count of the participants (indirectly) linked to a location. This is what I’m trying, but this query returns a row for each tournament, instead of grouping

How do I update a table with old value + the new value?

I have this SQL string which updates a row if it exists or creates a row if it does not, how do I do if it updates ctc_portfolio_coins_amount If I have a value of 100, or -100, how do I either substract it or add it to the current value when it updates? Table: Answer Arithmetic: The reference to ctc_portfolio_coins_amount

How do I pull last 5 entry from a from a table through SQL query?

I have a table with data entry like below. I want to select the last 5 rows all the time when new data will be inserted. So, product_id 2-6 will be selected in here. But when I will enter a new product, id 3-7 will be selected and afterwards.. What will be SQL query for this? I am newbie. Any

Updating table with datetime 6 hours advance

I wonder if this is possible I have easily done this with jQuery however I need it on a database that I have no control aside from updating it, what I want to accomplish is update it 6 hours advance let’s say time now is 1AM I’d like it to be 7AM This code works For getting current date and

Using a MIN MAX query over a DISTINCT one in MySQL?

With my new job, I am needing to use SQL more and more. As I need to remove duplicate columns I thought that using a DISTINCT statement would be best. However, I was indicated that a MIN MAX statement might be more suited. As I am still fairly new to SQL I was wondering if I could get some advice

MySql search integer range from number with dash

I have table in that I have one field with dash value. Like… I need to search this with between condition. For example if I have one value 25 then I need to search the records which include the value 25 like 20-31. In above image there are 6 records which include 25 value. So it should return 6 records.

Split comma separated string into rows in mysql

When I have string list like 1, 2, 3… I’d like to use this as one column Is it possible by sql query? ex) SELECT Ids from (1, 2, 3…) <- I know this is not working. Answer Use a subquery of arbitrary digits to split your string.Instead of vals you can use ‘1,2,3’. See it working

Advertisement