Avatar of Zack
ZackFlag for Australia

asked on 

SQL LIKE AND

Heyas,

Just a query is there a way you can combine and AND and LIKE statement for instance
select *
From galaxy
Where planets = "A"
AND constellation is LIKE 'NE%"

Cheers.
Microsoft SQL Server

Avatar of undefined
Last Comment
Zack
Avatar of X_layer
X_layer
Flag of Slovenia image

Try:
select *
From galaxy
Where ((planets = "A") AND (constellation is LIKE "NE%"))
ASKER CERTIFIED SOLUTION
Avatar of Eyal
Eyal
Flag of Israel image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Lee
Lee
Flag of United Kingdom of Great Britain and Northern Ireland image

select *
From galaxy
Where planets = 'A'
AND constellation LIKE 'NE%'

or

select *
From galaxy
Where planets = 'A'
AND constellation LIKE '%NE%'
Avatar of Reubenwelsh
Reubenwelsh

Why not:


select *
From galaxy
Where planets = "A"
AND constellation = "NE%"

Wont that give you the same effect? i dont see why you would want to add a LIKE
Avatar of Zack
Zack
Flag of Australia image

ASKER

Thank you for the tip
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo