Jump to content

Time issues db not mine


ecabrera
Go to solution Solved by Barand,

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
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";

Link to comment
Share on other sites

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

Edited by ecabrera
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.