Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Re: question ab...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 4 Topic 15431 of 17602
Post > Topic >>

Re: question about join

by ottavio@[EMAIL PROTECTED] (Ottavio Campana) May 1, 2008 at 07:54 PM

This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig1B598CBF4A8C06FE0237C288
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Osvaldo Kussama ha scritto:
>>  To further explain, the following query selects both the rows from th=
e join
>> where id_ref_first_tab has the desired value and default_value =3D tru=
e, while
>> I want to select the row corresponding to default_value =3D true only =
in case
>> no row corresponding to id_ref_first_tab exists.
>>
>>  select * from second_table join third_table on second_table.id =3D
>> third_table.id_ref_second_tab where id_ref_first_tab =3D 1 or default_=
value =3D
>> true;
>>
>>  I hope I've been clear enough...
>=20
> Try:
> select * from second_table join third_table on second_table.id =3D
> third_table.id_ref_second_tab
> where id_ref_first_tab =3D 1 or (id_ref_first_tab <> 1 and default_valu=
e =3D true);

it's not what I want, because it can return two rows, while I want only=20
one row back, checking the first condition and optionally the second one =

only if the first one is not matched.

I don't know if it is possible, but if it could, it would be great.

--=20
Non c'e' piu' forza nella normalita', c'e' solo monotonia.


--------------enig1B598CBF4A8C06FE0237C288
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIGgPpsbKx4ZV8clIRApXsAJ4qVYD0cNaDT2RJHPFOTUTzdhhP3ACfTTY9
K780tqtIsy3ln85efeUbrvg=
=EGbW
-----END PGP SIGNATURE-----

--------------enig1B598CBF4A8C06FE0237C288--
 




 4 Posts in Topic:
question about join
ottavio@[EMAIL PROTECTED]  2008-05-01 10:29:56 
Re: question about join
osvaldo.kussama@[EMAIL PR  2008-05-01 12:17:58 
Re: question about join
ottavio@[EMAIL PROTECTED]  2008-05-01 19:54:44 
Re: question about join
osvaldo.kussama@[EMAIL PR  2008-05-01 17:29:57 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Dec 1 18:52:58 CST 2008.