Solved

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

Posted on 2014-03-07
2
245 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

810 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