Skip to content
Advertisement

Tag: mysql

SQL: query repeating rows in join

I’m trying to display all my exercises which are in course A (course_id ‘1’) When I run this query: I get this: It’s worth noting that courses have sessions and in that session there are these exercises. Realistically only exercise_id’s 1 and 4 are linked to course 1. So why are their duplicate rows being returned? Session_id’s 10, 11, 12

Average value for top n records?

i have this SQL Schema: http://sqlfiddle.com/#!9/eb34d In particular these are the relevant columns for this question: ut_id,ob_punti I need to get the average of the TOP n (where n is 4) values of …

Select minute from CURTIME() in a sql query

I have a column with CURTIME() value. I want a query that selects the minute from the column with CURTIME() and copy the minute to another column. Answer You could use the minute function. If you’re just querying it: To save this value to another column:

SELECT if 2 cells in a row are equal

Tried to show it as simple as possible. I want to SELECT Subject if 2 cells in a row are equal Table Result I need is to select subject C cause username and lastpostername are equal (Sorted DESC by ID, so newest comes first) Answer

@SET (SQL) in PHP

How to state SET @unix_four_weeks_ago = UNIX_TIMESTAMP(curdate()) – 2419200; in php file. SQL PHP The query is all about getting the last 4weeks records. The query was working fine in SQL, but not giving any output when I run php file. Answer As the others already said, multi_query will allow you to run multiple statements in one go. However, this

UPDATE mysql rows

I’m trying to update a lot (close to 500) of rows in mysql database. How can I make it with just 1 query? …and it goes on and on until 500. Answer Use the BETWEEN operator: If not all products with an ID in that range should be updated, you’ll have to use the IN operator and construct the query

select where time = x or later

I have a table with columns username and timestamp . When a username is entered the current timestamp is as well. I would like to fetch the rows of all the new users from a certain time until now, but the start time varies. Lets make it a timestamp represented by x. I would like to use SQL to select

Advertisement