473,607 Members | 2,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error - trying to get only latest

Hi

I'm trying to get some data fra a few tables, but I'm having a few
problems.

What I would like is this:

The tables contain somn info on manuscripts and which process that
manuascript has received.

a manuscript is represented once in manuascript table
that manuascript can have several records in the process table.

What I want is to get data for each manuscript and the last process that
the manuscript received from the process table.
This SQL gets the manuscript for each process it has received. SO if a
manuscript has 5 process records I will get 5 records back...

SELECT
Manuscript.m_id , Manuscript.uniq ueIDCountry,
Manuscript.uniq ueIDNo, Manuscript.m_ti tle,
Manuscript.coun try, Manuscript.m_re ceivedDate,
Process.p_id, Process.m_id, Process.process Date,
ProcessTypes.ps _id, ProcessTypes.pr ocessName
FROM
Manuscript,
Process,
ProcessTypes
WHERE [Process].m_id = [Manuscript].m_id
AND [Process].ps_id = [ProcessTypes].ps_id
Please help... I'm getting desperate..
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
2 1369
Try (untested)

SELECT
M.m_id,
M.uniqueIDCount ry,
M.uniqueIDNo,
M.m_title,
M.country,
M.m_receivedDat e,
P.p_id,
P.m_id,
MAX(P.processDa te) AS ProcessDate,
PT.ps_id,
PT.processName

FROM
Manuscript M
LEFT JOIN Process P
ON M.M_Id = P.M_Id
LEFT JOIN ProcessTypes PT
ON P.PS_Id = PT.PS_Id

GROUP BY
M.m_id,
M.uniqueIDCount ry,
M.uniqueIDNo,
M.m_title,
M.country,
M.m_receivedDat e,
P.p_id,
P.m_id,
PT.ps_id,
PT.processName

I've taken a guess that the max of the ProcessDate from your process
table will give you the last record that you want. You may need to
look at which columns are appropriate for giving you the correct
record, your column names aren't the most helpful hence the guess. The
left join is what you were missing though.

I've not added in anything for your third table and assumed that it is
a stright one to one relationship, but you should easily see how to do
anything further. I've also added some table aliases and tidied things
up a bit to make it easier to read.

Hope that helps

Ryan

Thomas Stark <st***@newident ity.dk> wrote in message news:<41******* *************** @news.newsgroup s.ws>...
Hi

I'm trying to get some data fra a few tables, but I'm having a few
problems.

What I would like is this:

The tables contain somn info on manuscripts and which process that
manuascript has received.

a manuscript is represented once in manuascript table
that manuascript can have several records in the process table.

What I want is to get data for each manuscript and the last process that
the manuscript received from the process table.
This SQL gets the manuscript for each process it has received. SO if a
manuscript has 5 process records I will get 5 records back...

SELECT
Manuscript.m_id , Manuscript.uniq ueIDCountry,
Manuscript.uniq ueIDNo, Manuscript.m_ti tle,
Manuscript.coun try, Manuscript.m_re ceivedDate,
Process.p_id, Process.m_id, Process.process Date,
ProcessTypes.ps _id, ProcessTypes.pr ocessName
FROM
Manuscript,
Process,
ProcessTypes
WHERE [Process].m_id = [Manuscript].m_id
AND [Process].ps_id = [ProcessTypes].ps_id
Please help... I'm getting desperate..
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 20 '05 #2

Thanks a lot.

Yeah thats pretty much what I was looking for.

I've spent hours trying to sort it out.. Maybe I should try and learn a
bit more SQL..
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4870
by: mike | last post by:
I get the following line when trying to uncomment the extension=php_oci8.dll line in my php.ini file. ------------------------------------------------- PHP Warning: Unknown(): Unable to load dynamic library 'c:\php\extensions\php_oci8.dll' - The specified procedure could not be found. in Unknown on line 0 -------------------------------------------------
4
15338
by: gc | last post by:
I'm a PHP and MySQL newbie. I have a feeling a lot of you may have seen this before. I'm teaching myself PHP/MySQL and trying to setup a guestbook. I'm running latest versions of Apache, PHP and MySql on WIN 2000. PHP is installed from the zip file. When serving php docs (code snippets below) I get the messages: "Fatal error: Call to undefined function mysql_connect() " "Fatal error: Call to undefined function mysql_pconnect() "
1
5878
by: qwejohn | last post by:
Hello, I had posted this question in the twisted mailing list but did not got a solution ; I hope that the python Gurus of this forum can help me a bit. I am trying the exmaple in the python docs - http://twistedmatrix.com/users/warner/doc-latest/web/howto/using-twistedweb.xhtml Configuring and Using the Twisted.Web Server - Twisted Web Development.
0
2620
by: Jeremiah Jacks | last post by:
I just upgraded to MySQL 4.0.14-standard for RedHat Linux and am using = the pre-compiled binaries. I have a database with INNODB tables. When I insert a row into one of the child tables, I get the following = MySQL error: INSERT INTO product_access_level (product_id,access_level_id) VALUES
0
277
by: Fiona McBride | last post by:
Hi all, I have a really odd problem with some Visual Basic .NET 2003 code; I have a program that creates a number of windows which contain RichTextBox, Timers (disabled) and menus. The code runs fine and creates the windows as required, BUT if the program is left to do nothing for several hours, when it is brought back into focus it generates an exception error (Object reference not set to instance of an object - this always coincides...
0
1937
by: Scotter | last post by:
Hi - I posted this message in the microsoft.public.inetserver.iis group, as well. I hope someone can help. My client is frantic. Platform: Windows 2003 Server Enterprise Edition, latest MDAC 2.8 Trying to run this ASP.NET app. It has worked before. No code has changed so I'm convinced the problem is with some server settings.
20
5309
by: ctyrrell | last post by:
Does anyone have any idea how to recover from a run-time error 3002 which I get after creating a workspace 242 times? Or better yet, avoid getting it in the first place? I am creating a workspace with a blank password for different Users in order to find out which Users do not have passwords. This works just fine if I do it a few times, but if I want to do it periodically with a loop, it bombs out after 242 times of finding a user with...
1
2628
by: Daniel Secomb | last post by:
Hi, I'm using PostgreSQL 7.3.4 with phpPgAdmin 2.4.2 and the ".sql" file I'm trying to import came from a dump from a server running PostgreSQL 7.0.3. I just got this error message trying to import the PostgreSQL database file into phpPgAdmin. The error message was as follows: Error - /usr/local/psa/admin/htdocs/domains/databases/phpPgAdmin/db_readdump.php --
3
5860
by: anagai | last post by:
hi I am trying to install the java bridge library for php 5.1.2. I have installed the j2see 1.4 and jdk. I have setup the section in php.ini as follows: java.classpath = "c:/PHP/ext/JavaBridge.jar;" java.java_home = "c:/Sun/AppServer/jdk/bin" java.libpath = "c:/PHP/ext"
0
5754
by: Benny | last post by:
I have been trying to instal AutoCAD 2008 on a single PC and get the following Microsoft .NET Framework security error. I have updated to the latest .NET Framework 2.0 software, however, this error occurred with only v1.1 installed. I also got the same error when trying to install an old ACAD 2005 version (as a check). I have successfully installed this version a couple of years ago.
0
8050
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
8130
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
8324
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6000
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
5471
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
3954
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
4015
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2464
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
0
1318
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.