Is there simple way to select updated rows? I’m trying to store timestamp each time I am read row to be able to delete data that was not readed for a long time. First I tried execute SELECT query first and even found little bit slow but simple solution like but I still want to find a normal way to
Tag: mysql
MYSQL, How to combine the first 2 letters of the first name and the first 5 letters of the last name
I’m trying to write an SQL query (using the SELECT function) that will take the first two letters of the first name and the first 5 letters of the last name, then combine them and put them in a new column called “User Name.” I’ve tried using the SUBSTRING and CONCAT functions together, but my syntax isn’t right. Does anyone
Query using min() not showing the correct result
I have this table: CREATE TABLE IF NOT EXISTS `Vars` ( `ID` bigint(20) NOT NULL AUTO_INCREMENT, `code` varchar(15) NOT NULL, `userID` bigint(20) NOT NULL, `viewedT` bigint(20) NOT NULL, …
If pagename then run statment
I’m building a blog and have two tables articles and categories and I’m joining these tables, but what I want to do is display just the categories if I click a categories link. I’m passing the …
Select one row with MAX(column) for known other several columns without subquery
My table contains votes of users for different items. It has the following fields: I understand how to get the last vote of #user# for #item#, but it uses subquery: It works, but it looks quite stupid to me… There should be a more elegant way to get this one record. I tried the approach suggested here, but I cannot
Having trouble with WHERE DATEDIFF in my SQL
I think I’m going about this wrong. I want to pull the rows in my database that are less than a day old, in PHP. I’m using Laravel, but that’s not relevant. Here is what I have: However, that isn’t return the right results. It’s return results older than a day. Answer This query selects rows that are newer than
Get GPS data (lat, lon, address) for each truckId with the latest timedate
I have the following table : main(rowId, posDatetime, truckId, lat, lon, address) rowId: PK posDatetime: the date and time of the coordinates and address truckId lat,lon address: address string rows are not fed in datetime order. to get the latest position for each truck I hit the DB with this query FOR EACH truck: SELECT * FROM main WHERE truckId=XXXX
MySQL Error 1264: out of range value for column
As I SET cust_fax in a table in MySQL like this: and then I insert value like this: but then it say `error 1264` out of value for column And I want to know where the error is? My set? Or other? Any answer will be appreciated! Answer The value 3172978990 is greater than 2147483647 – the maximum value for
SELECT id HAVING maximum count of id
Have a products table with item_id and color_id. I’m trying to get the color_id with the most non-null instances. This fails: with This Returns I am looking for color_id 3, which has the most instances. Is there a quick and easy way of getting what I want without 2 queries? Answer This will give you the color_id and the count
Can’t see MySQL BIT field value when using SELECT
my_table contains the enabled field which is defined as: enabled BIT NOT NULL DEFAULT 0. This table has multiple rows with enabled = b’0′, and multiple rows with enabled = b’1′. However, both this: …