+ Reply to Thread
Results 1 to 2 of 2

SQL query writing

Hybrid View

  1. #1
    Registered User
    Join Date
    11-16-2014
    Location
    southern california
    MS-Off Ver
    2007
    Posts
    3

    SQL query writing

    I am trying to write a query in Microsoft SQL that searches for data using using the first initial and last name...I have no idea how to concatenate these 2 columns into 1 string... Below is the basic writing of what I am trying to get at:

    select fname, lname, concat(left(fname,1),lname)
    from data
    where concat(left(fname,1),lname) ='SSmith'

    Any help would be appreciated! Thanks

  2. #2
    Registered User
    Join Date
    12-23-2013
    Location
    Gurgaon
    MS-Off Ver
    Excel 2013
    Posts
    36

    Re: SQL query writing

    Hi hom100,

    You can use CONCAT function for concatenation in SQL. You can refer below eg for the same

    eg : select CONCAT(fname,lname) from person where pid = 56


    Another eg:

    SELECT
    Title,
    FName,
    LName,
    CONCAT(FName,' ',LName) as Name
    FROM Emp.Info
    Last edited by maitrayk; 01-10-2015 at 03:41 AM.
    Maitray,

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Having trouble writing a SELECT query
    By mc84excel in forum Access Tables & Databases
    Replies: 15
    Last Post: 03-23-2015, 08:19 PM
  2. [SOLVED] Help writing query that extracts numeric and alphanumeric information at same time
    By alcharbonneau in forum Access Tables & Databases
    Replies: 3
    Last Post: 03-04-2013, 03:39 PM
  3. Writing SQL query to import specific data to a pivot tableatabase
    By Richard Buttrey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-21-2008, 10:10 AM
  4. Problem in getting writing sql query output data to file
    By suhas.nehete in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-05-2008, 01:01 AM
  5. writing excel VBA Query for fetching data from Access
    By vikas.bhandari in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-16-2007, 05:47 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1