suprsnipes Posted May 29, 2009 Share Posted May 29, 2009 This is the SQL query. I'm not having a problem with this, but it's the steps afterwards, firstly let me explain what I am trying to do. CREATE TABLE t3 AS (SELECT * FROM t1 INNER JOIN t2 on t1.id=t2.id-1) id-1 represents the previous row (entry), id is set to auto_increment. What you can see from this is I that am joining these two tables together so that I can compare the row of data prior. Whilst this query works this is my problem. I would like to know if there is a better way to do this because I may need to run a query from id to perhaps id-20. otherwise I need to perform the query above many, many times. By the way once I have joined the tables the query I need to run is as follows; SELECT * FROM t3 WHERE column1=a AND column2<=column3 Appreciate the help. Link to comment https://forums.phpfreaks.com/topic/160128-sql-query-for-mysql-running-a-query-on-a-row-against-another-row/ Share on other sites More sharing options...
suprsnipes Posted May 30, 2009 Author Share Posted May 30, 2009 21 views and not one reply...bit harsh Link to comment https://forums.phpfreaks.com/topic/160128-sql-query-for-mysql-running-a-query-on-a-row-against-another-row/#findComment-845556 Share on other sites More sharing options...
fenway Posted June 6, 2009 Share Posted June 6, 2009 Wait... whyare you creating a new table to do this? Link to comment https://forums.phpfreaks.com/topic/160128-sql-query-for-mysql-running-a-query-on-a-row-against-another-row/#findComment-850486 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.