How can i use Left Join in an SQL as well as use Like command in the same sql statement. And can you please give me various examples of the codes i can use as well as the table generated from the SQL statement.
1 2144 Atli 5,058
Recognized Expert Expert
Hi, and welcome to TSDN.
Do you mean something like this? -
SELECT
-
CONCAT(
-
tUser.LastName,
-
',',
-
tUser.FirstName
-
) AS 'Name',
-
CONCAT(
-
tAddress.StreetName, ' ',
-
tAddress.StreetNumber, ', ',
-
tAddress.CityName
-
) AS 'Address'
-
FROM userTable AS tUser
-
LEFT JOIN addressTable AS tAddress
-
ON tAddress.userID = tUser.userID
-
WHERE tUser.LastName
-
LIKE '%an%'
-
AND tAddress.Country
-
LIKE '%america%'
-
ORDER BY
-
tUser.LastName
-
Which might generate something like this: -
Name Address
-
------------------------------------------
-
Anderson, Pamela Someroad 6, Los Angeles
-
Cartman, Eric Street 666, South Park
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Soefara |
last post by:
Dear Sirs,
I am experiencing strange results when trying to optimize a LEFT JOIN
on 3 tables using MySQL.
Given 3 tables A, B, C such as the following:
create table A (
uniqueId int not null default 0 auto_increment,
a1 varchar(64) not null default '',
|
by: Wim Rafera |
last post by:
I would like to use a "LIKE" condition in my LEFT JOIN statement.
At the moment I have something like:
SELECT * FROM page AS p LEFT JOIN item AS i ON p.url=i.url
Now I want to include the subpages from i.url. So if p.url is
"www.here.com/page"
it should also match if i.url is
"www.here.com/page/subpage.html"
|
by: Paul Bramscher |
last post by:
Here's one for pathological SQL programmers.
I've got a table of things called elements. They're components, sort of
like amino acids, which come together to form complex web pages -- as
nodes in trees which form parent-child relationships, sort of like
newsgroups. For example, the parent_id field points to another element.
Indent_level is there for denormalization purposes, to avoid costly
recursive issues in querying. The...
|
by: Scott Snella |
last post by:
Hi, I hope this is the right place to post, but, I am having a problem with
an UPDATE command and a LEFT JOIN, I am using something like:
UPDATE table_a LEFT JOIN table_b ON table_a.field1=table_b.field1 SET
table_b.field6='1' WHERE table_a.field2='1';
Something along those lines. Anyway, from what I can see on various web
sites, documentation, etc, I think it should work, however, I keep getting
this error...
|
by: Dam |
last post by:
Using SqlServer :
Query 1 :
SELECT def.lID as IdDefinition,
TDC_AUneValeur.VALEURDERETOUR as ValeurDeRetour
FROM serveur.Data_tblDEFINITIONTABLEDECODES def,
serveur.Data_tblTABLEDECODEAUNEVALEUR TDC_AUneValeur
where def.TYPEDETABLEDECODES = 4
| |
by: Thomas Beutin |
last post by:
Hi,
i've a speed problem withe the following statement:
SELECT DISTINCT pz.l1_id, pz.l2_id, pz.l3_id, pz.l4_id
FROM ot_adresse AS a, ot_produkt AS p
LEFT OUTER JOIN ot_kat_prod AS pz ON ( p.p_id = pz.p_id )
WHERE p.a_id = a.id AND a.id = '105391105424941' AND a.m_id = '37';
This is terrible slow compared to the inner join:
SELECT DISTINCT pz.l1_id, pz.l2_id, pz.l3_id, pz.l4_id
|
by: Zengfa Gao |
last post by:
Hi, all,
I tried to use "left join" to select data from my
database. Result is come out, but I didn't see the
value of "displayString". I added "left outer join",
same result.
SELECT devices.ProductType, devices.deviceKey,
devices.fullDNSName, deviceTypesEnum.displayString,
deviceTypesEnum.enumId FROM devices
|
by: Ian Boyd |
last post by:
i know nothing about DB2, but i'm sure this must be possible.
i'm trying to get a client to create a view (which it turns out is called a
"Logical" in DB2). The query needs a LEFT OUTER JOIN, but he doesn't know
how to do that, or even if he can, and i don't have to time to learn DB2
from scratch right now.
The following SQL Query is a trimmed sample of the full View (i.e. Logical)
definition - and i would create it on an SQL based...
|
by: yeahuh |
last post by:
Quick and dirty version.
Godaddy server using MySQL 4.0.24
I’m trying a left join to obtain id’s in table A(cars) that are NOT in car_id in table B(newspaper):
*This is a cut down version to simplify testing. Full version is posted towards the end.
SELECT C.id
FROM cars C LEFT OUTER JOIN newspaper N USING (C.id=N.car_id)
WHERE N.car_id IS NOT NULL;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |