dbTalk Databases Forums  

a special query....

comp.databases.mysql comp.databases.mysql


Discuss a special query.... in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Fabio Codebue @ GestionaleOpen
 
Posts: n/a

Default a special query.... - 03-19-2010 , 08:09 AM






this is the SQL:
select ovt.progressivo as progressivo,
(case when opt.progressivo is null then ovt.situazione
when ovt.situazione='evaso' then 'pronto'
else 'in lavorazione'
end) as situazione,
ovt.*, tdo.descrizione tdo_descrizione
from ovt
inner join tdo on tdo.codice = ovt.tdo_codice
left join opt on opt.cms_codice=ovt.cms_codice and opt.tipologia=ovt.tipologia
where ovt.cli_codice = '00002043' and ovt.situazione = 'inserito'
order by ovt.tdo_codice, ovt.data_documento, ovt.numero_documento


I have 3 tables: ovt, tdo and opt

relations are

ovt -->tdo n-->1
ovt -->opt 1-->n

I need to have a row for every ovt rows with a field that change value if there is a link into opt table (field situazione)

but if I have more than 1 row into opt related to ovt I have back n ovt row instead one!

codebue fabio
p-soft

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.