MySQL query to append character to each entry
Scenario: You want to append a string or character at the beginning of a db field. solution: UPDATE Tablename SET Username = Concat(‘0’, Username);
Scenario: You want to append a string or character at the beginning of a db field. solution: UPDATE Tablename SET Username = Concat(‘0’, Username);
Scenario: You have a field in database where you want to add it all with a number for example: 1000; you can update all of them like this: UPDATE mysql_table SET user_id = 1000 + user_id;
SELECT * FROM TABLE WHERE HOUR(time) BETWEEN 1 AND 2; This query brings all records between 1 and 2 o’clock according to time field of you table. (time = The DB field which you save the time)
You can check if a record exist in a specific table of database in MySQL with the code block below: if(mysql_num_rows(mysql_query(“SELECT * FROM reports WHERE reportID = ‘$reportNUM'”))){ // Code inside if block if reportID is already there }
Bunun için; çekeceğiniz query’nin sonunda şunlar ekliyorsunuz:(Kalın olarak yazılan kismi) $sorgu=mysql_query(“SELECT * FROM table ORDER by rand() LIMIT 1“); Daha fazlası icin bu makaleyi inceleyiniz: http://www.learningmovabletype.com/a/001037random_quotes/