Jump to content

Time issues db not mine


ecabrera

Recommended Posts

OK so im using a database from a website that lets you use their embed videos the database contains the name, embed videos , time , keywords , category . The time is a varchar type because when i opened the csv file it wasn't saved as a timestamp it was saved like this '324 sec' , '524 sec' so i made it a varchar

 

what i want to do is make it so that when user click the option to see videos that are 10 mins or longer the can

 

but it doesnt work

 

here is the sql i used

SELECT * FROM `videos` WHERE `time` > '600 sec'
Link to comment
https://forums.phpfreaks.com/topic/283138-time-issues-db-not-mine/
Share on other sites

1. BACK UP YOUR TABLE

 

2. Run this update query to strip the " sec" from the time column values.

UPDATE videos SET time = SUBSTRING_INDEX(time,' ',1);

3 Now change the column type to INT with

ALTER TABLE `videos` CHANGE COLUMN `time` `time` INT NULL DEFAULT NULL  ;

Your query should now work if all the times were in the same format "999 sec";

THANK YOU

 

1. BACK UP YOUR TABLE

 

2. Run this update query to strip the " sec" from the time column values.

UPDATE videos SET time = SUBSTRING_INDEX(time,' ',1);

3 Now change the column type to INT with

ALTER TABLE `videos` CHANGE COLUMN `time` `time` INT NULL DEFAULT NULL  ;

Your query should now work if all the times were in the same format "999 sec";

 

 

know i tried to add more option to the sql 

 

tags are the keywords 

 

im trying to make it so that the user gets videos that have those keywords and or above 10min

SELECT * FROM `videos` WHERE `time` > '600' AND `tags` LIKE '%play%' OR `tags` LIKE '%soccer%' OR `tags` LIKE '%ronaldo%'

but thats when it gives me different time is it the fact that im using AND

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.