473,398 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Left Join and Like command used together

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.
Jun 16 '07 #1
1 2123
Atli
5,058 Expert 4TB
Hi, and welcome to TSDN.

Do you mean something like this?
Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.   CONCAT(
  3.     tUser.LastName, 
  4.     ',', 
  5.     tUser.FirstName
  6.   ) AS 'Name',
  7.   CONCAT(
  8.     tAddress.StreetName, ' ',
  9.     tAddress.StreetNumber, ', ',
  10.     tAddress.CityName 
  11.   ) AS 'Address'
  12. FROM userTable AS tUser
  13. LEFT JOIN addressTable AS tAddress
  14.   ON tAddress.userID = tUser.userID
  15. WHERE tUser.LastName
  16.   LIKE '%an%'
  17. AND tAddress.Country
  18.   LIKE '%america%'
  19. ORDER BY
  20.   tUser.LastName
  21.  
Which might generate something like this:
Expand|Select|Wrap|Line Numbers
  1. Name              Address
  2. ------------------------------------------
  3. Anderson, Pamela  Someroad 6, Los Angeles
  4. Cartman, Eric     Street 666, South Park
Jun 17 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
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...
2
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...
1
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...
2
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...
3
by: Dam | last post by:
Using SqlServer : Query 1 : SELECT def.lID as IdDefinition, TDC_AUneValeur.VALEURDERETOUR as ValeurDeRetour FROM serveur.Data_tblDEFINITIONTABLEDECODES def,...
6
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 (...
1
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 ...
3
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...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
tracyyun
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.