473,614 Members | 2,084 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 1553
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
2539
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 users uploading data into a database. I want to do something that seems as if it should be really simple, but it isn't so far. Basically, I want to retrieve the latest 12 records from the table, sorted by the date-time field (uploaddate) then...
1
3428
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 include a date field. How can I force the sub form to display the most recent dates by default, verses forcing the user to scroll through all of the records to the bottom of the form in order to view the most recent entry or to add a new entry...
1
10605
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 accomplish this?
3
1854
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 examhistory.coursekey, students.userid, students.firstname, students.lastname, examhistory.examdate,coursekeylookup.examdescription FROM students, examhistory, coursekeylookup AND students.userid='1234567'
9
1717
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 managed this by creating another table but Im sure it can be done with a couple of queries.
2
4831
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 trainings. The table only lists the employee number and it is related to a table which includes the employees' names and the employees' numbers. I would like my query to look at each employee and find all the records where they have taken, for...
1
2936
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 txtSerialNumber_Enter() Dim txtLotNumber As String Dim txtSerialNumber As String 'Dim db As Database 'Set db = OpenDatabase("Modem.mdb")
2
3282
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 records (N is 1) - most recent records 10-20 (N would be 2) - most recent records 10-30 (etc.)
10
7965
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 different tables as well. Since my description is usually inadequate, here's a simple example: Before Query: Date Field 1/1/07 A 1/2/07 A 1/2/07 B
13
4015
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. It also has ItemNumber and LatestUsedDate. Table 2 may not have any record for an ItemNumber in Table 1; it may have one record; or it may have several records for a given ItemNumber. Sometimes the LatestUsedDate is filled in; sometimes...
0
8182
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8279
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7093
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6088
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5540
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4052
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4127
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2568
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 we have to send another system
1
1747
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.