473,498 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get the most recent records comparing them on multiple tables

10 New Member
Hi, I'm trying to get in my homepage the last 10 product-schedules inserted in my website. These I should get from different tables in my database, that have all the same fields but every table has a different kind of product.

So, I should virtually join all the tables and then get of these the 10 tables with the most recent date.
The problem is that I'm able to do this, but just on one table:
Expand|Select|Wrap|Line Numbers
  1. require("db/db.php");
  2. $lastinserted=mysql_query("SELECT img,link,numclick,description,order FROM $table1 ORDER BY date DESC, order LIMIT 0,1",$link);
  3. while ($row=mysql_fetch_array($lastinserted,MYSQL_NUM)) {
  4. printf("<div class='grid_8'><div class='screen'>%s</div><div class='text'><h2>%s<span class='visite'> &nbsp;- %s visite</span></h2> %s</div></div>", $row[0], $row[1], $row[2], $row[3]);
  5. }
  6. mysql_free_result($lastinserted);
  7. mysql_close($link);
  8.  
I guess I should use the 'join' command but I have no idea how…
some advice?
thanks a lot
Jul 22 '10 #1
1 1544
deiv82
10 New Member
ok i've resolved the problem using UNION ALL!

thanks however

byebye
Jul 22 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2522
by: Randy Jackson | last post by:
First of all, I apologize in advance if this is covered somewhere in a FAQ. I did a Google search, but really couldn't find anything. I'm having a problem with a simple select query. I've got...
1
3419
by: Tim Graichen | last post by:
Good morning, I have a sub-form that displays records from a table as a continuous form. The table has several hundred records, but the subform only displays five or six records. The records do...
1
10570
by: Brian | last post by:
I'm trying to find a way to search multiple tables for the same record. Say I have 3 tables all with a name column, I need to search all 3 tables and find matching names. Is there an easy way to...
3
1849
by: manny | last post by:
Problem: how to have query show only most recent records. This query shows all exams in 2005 for particular individual (grades not shown to avoid embarrassing John Slacker!): SELECT...
9
1707
by: shumit | last post by:
Hi I have a patient table with patient names and visiting dates. I want to select those patients who have visited me at least 6 times and show the dates that they visited ordered by name. I have...
2
4821
by: gafchic | last post by:
I manage a training database where I work and I would like to run a make table query. The table I want to query has a list of trainings our employees have taken and the dates they have taken the...
1
2923
by: access345 | last post by:
I am trying to add a record to multiple tables at the same time. My current Code created multiple records in the same table. I am trying two different methods with no results: Public Sub...
2
3276
by: robert.waters | last post by:
I need to perform the following: - select the most recent X number of records in a table (there is a timestamp field) - select the Nth occurrence of X number of records ex: - most recent 10...
10
7937
by: rousseaud | last post by:
Hello- I'm having a little trouble. I want to create a query that will return the most recent records (by date) for all unique values in a certain field in the query. I'll be pulling data from 3...
13
3996
by: angi35 | last post by:
Hi - working in Access 2000... my goal is to combine fields from two tables in a query: Table 1 has ItemNumber and ItemDescription. There's only one record per ItemNumber. Table 2 has ItemAlias....
0
7121
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6993
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6881
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4584
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.