Solved

which syntax is the correct sql syntax for working with inner join?

Posted on 2014-03-07
2
244 Views
Last Modified: 2014-03-07
// This way works fine in FireBird Dabatase

 Select distinct A.* from GlCli A
 inner join CFCLI1 B on (B.codcli=a.codcli and B.codempresa=1 and B.tipocli='C')
 where (lower(A.apelido) like '%teste%')
 or (lower(A.nome) like '%teste%')
 or (A.CGC like '%teste%')


// This way doesn't work in FireBird but works in MSSQL

Select distinct A.* from GlCli A
inner join CFCLI1 B on B.codcli=a.codcli
Where B.codempresa=1
  and B.tipocli='C')
  And (lower(A.apelido) like '%teste%')
or (lower(A.nome) like '%teste%')
 or (A.CGC like '%teste%')

Open in new window


Thanks
Alex
0
Comment
Question by:hidrau
2 Comments
 
LVL 11

Accepted Solution

by:
David Kroll earned 500 total points
ID: 39913327
They're both correct.  I prefer to have all conditions related to a join in the actual join code, like the top example.  It's just easier to see every condition in one place for me.
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 39913474
thanks very much
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now