Solved

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

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

10 Experts available now in Live!

Get 1:1 Help Now