SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    563
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Help to get INT only when using CONCAT in SQL query

    Hi,

    I have a sql query in which in concatenating 2 fields.
    Is there any way to get only values which are numbers after doing concat ??

    Code:
    SELECT devbg_products.*, devbg_categories.*, devbg_subcategories.*, lockmfgs.* FROM devbg_products 
    LEFT JOIN devbg_categories ON devbg_products.ItemCategory = devbg_categories.CategoryID 
    LEFT JOIN devbg_subcategories ON devbg_products.ItemSubcategory = devbg_subcategories.SubcategoryID 
    LEFT JOIN lockmfgs ON devbg_products.ItemLockID = lockmfgs.LockID WHERE 
    85111 >= CONCAT(devbg_products.RngPrefix, devbg_products.StrRange) AND 
    85111 <= CONCAT(devbg_products.RngPrefix, devbg_products.EndRange) AND 
    devbg_categories.Status = '0' ORDER BY devbg_products.ItemName
    Its comparing 85111 value with concatenated values 3E001 and 3E350 respectively which is wrong.
    If after concatenating the value is not numeric then it should be ignored.

    Thats what I am trying to achieve but don't know how to do. Please help.

    Thanks.

  2. #2
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    563
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I did cast(CONCAT(devbg_products.RngPrefix, devbg_products.StrRange) AS UNSIGNED) and its working.

    Thanks.


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
  •