Unix Technical Forum

Re: how to find the maximum id from two tables

This is a discussion on Re: how to find the maximum id from two tables within the Informix forums, part of the Database Server Software category; --> Frank Langelage said: > > The JBossAS tries to execute this query and gets a syntax error: > SELECT ...


Go Back   Unix Technical Forum > Database Server Software > Informix

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 09:57 AM
Obnoxio The Clown
 
Posts: n/a
Default Re: how to find the maximum id from two tables


Frank Langelage said:
>
> The JBossAS tries to execute this query and gets a syntax error:
> SELECT MAX(TXID) FROM (
> SELECT MAX(TXID) AS TXID FROM JMS_TRANSACTIONS
> UNION
> SELECT MAX(TXID) AS TXID FROM JMS_MESSAGES
> )
>
> The goal is to find the maximum txid out of two tables with one query.
> I know I may create a view for the union select and select the max from
> this view.
> But I'd like to avoid this and use one query against the tables on my
> IDS 10 server.


Do you want both maxima, or just the bigger of the two?

--
Bye now,
Obnoxio

"C'est pas parce qu'on n'a rien ` dire qu'il faut fermer sa gueule"
- Coluche

did i mention i like nulls? heck, i even go so far as to say that all
columns in a table except the primary key could/should be nullable. this
has certain advantages, for example, if you need to insert a child record
and you don't have a parent row for it, just do an insert into the parent
table with the primary key value (everything else null), and voila,
relational integrity is preserved. but this is, admittedly, a bit
controversial among modellers.

--r937, dbforums.com
sending to informix-list
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 09:57 AM
Captain Pedantic
 
Posts: n/a
Default Re: how to find the maximum id from two tables

"Obnoxio The Clown" <obnoxio@serendipita.com> wrote in message
news:doekll$n0s$1@news.xmission.com...
>
> Frank Langelage said:
>>
>> The JBossAS tries to execute this query and gets a syntax error:
>> SELECT MAX(TXID) FROM (
>> SELECT MAX(TXID) AS TXID FROM JMS_TRANSACTIONS
>> UNION
>> SELECT MAX(TXID) AS TXID FROM JMS_MESSAGES
>> )
>>
>> The goal is to find the maximum txid out of two tables with one query.
>> I know I may create a view for the union select and select the max from
>> this view.
>> But I'd like to avoid this and use one query against the tables on my
>> IDS 10 server.

>
> Do you want both maxima, or just the bigger of the two?


Can you have a bigger maxima of the two?


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:40 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com