I would like to combine FirstName
and LastName
into one column called 'FULL NAME'
and search with LIKE in SQL.
Example 1:
FirstName : Milan
LastName: PatelFullName: Milan Patel
Search with: Like '%SomeText%'
Example 2:
Title: " Meetings: A practical alternative to work."
Search: I would like to search the entire word within the give string. ex: work should return the above title.
Here is what I have so far.
SELECT
CE.Title, CC.FirstName + ' ' + CC.LastName AS FullName
FROM
EntryTable CE
JOIN
UserTable CC ON CE.EntryId = CC.USerId
WHERE
CC.FirstName LIKE 'n%'
I am getting it there slowly. search is working fine with this query.
SELECT
CE.Title
FROM
EntryTable CE
JOIN
UserTable CC
ON
CE.EntryId = CC.USerId
WHERE
CC.FirstName + ' ' + CC.LastName LIKE 's%'
BUT it only search for name starting with 's'
, i would like to search name starting, ending, contains conditions as well. how can i go about that. please help
Let's say you want to create a single Full Name column by combining two other columns, First Name and Last Name. To combine first and last names, use the CONCATENATE function or the ampersand (&) operator.
Is there as way to combine the "in" and "like" operators in Oracle SQL? Answer: There is no direct was to combine a like with an IN statement.
To find the duplicate Names in the table, we have to follow these steps: Defining the criteria: At first, you need to define the criteria for finding the duplicate Names. You might want to search in a single column or more than that. Write the query: Then simply write the query to find the duplicate Names.
You can use LIKE
with concatenated column values as below
WHERE
CC.FirstName + ' ' + CC.LastName LIKE 's%'
BUT it only search for name starting with 's', i would like to search name starting, ending, contains conditions as well. how can i go about that. please help
Then you have to use %
before and after search string like below
WHERE
CC.FirstName + ' ' + CC.LastName LIKE '%s%'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With