Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Search within a table

SQL Search within a table

Scheduled Pinned Locked Moved Database
helpdatabase
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    veon cheng
    wrote on last edited by
    #1

    Good day, I have some problem with my SQL Commands in access, really hope that you can help me out. Category

    CatID Category Name Sub- Category Description

    1 Beverages 123
    2 Condiments 456
    3 Juice 1 help
    4 Coffee 1 pls

    I wanted to display the main category of the Juice which is beverage. No matter how hard i tried, i can't display the Main category in access. Really hope if any kind soul could help me with this Regards Veon

    C I 2 Replies Last reply
    0
    • V veon cheng

      Good day, I have some problem with my SQL Commands in access, really hope that you can help me out. Category

      CatID Category Name Sub- Category Description

      1 Beverages 123
      2 Condiments 456
      3 Juice 1 help
      4 Coffee 1 pls

      I wanted to display the main category of the Juice which is beverage. No matter how hard i tried, i can't display the Main category in access. Really hope if any kind soul could help me with this Regards Veon

      C Offline
      C Offline
      Corporal Agarn
      wrote on last edited by
      #2

      Could you please show your SQL.

      V 1 Reply Last reply
      0
      • C Corporal Agarn

        Could you please show your SQL.

        V Offline
        V Offline
        veon cheng
        wrote on last edited by
        #3

        Sorry its kinda messy, its from access.. the bold part is the 1 have issue. once againg sorry

        SELECT Product.[Electronic Product Code], Product.[Item Name], IIf([parent - category] Is Null,[name],[Category].[name]=[category].[Category ID].[name]) AS Category , IIf([Parent - Category] Is Not Null,[name],"") AS SubCategory, Location.Country, Location.Building, Location.[Street Address], [Tracking Record].Timestamp, [RFID Reader].[Reader ID]
        FROM Location RIGHT JOIN ((([RFID Reader] RIGHT JOIN (Product LEFT JOIN [Tracking Record] ON Product.[Electronic Product Code] = [Tracking Record].[Electronic Product Code]) ON [RFID Reader].[Reader ID] = [Tracking Record].[RFID Reader ID]) LEFT JOIN Has ON Product.[Electronic Product Code] = Has.[Electronic Product Code]) LEFT JOIN Category ON Has.[Category ID] = Category.[Category ID]) ON (Location.Latitude = [Tracking Record].Latitude) AND (Location.Longtitude = [Tracking Record].Longtitude)
        WHERE (((Product.[Electronic Product Code]) Like "*" & [forms]![Search History]![tbxEPC] & "*") AND ((Product.[Item Name]) Like "*" & [forms]![Search History]![tbxProductName] & "*") AND ((Category.[Category ID])=[forms]![Search History]![cmbCat])) OR (((Product.[Electronic Product Code]) Like "*" & [forms]![Search History]![tbxEPC] & "*") AND ((Product.[Item Name]) Like "*" & [forms]![Search History]![tbxProductName] & "*") AND (([forms]![Search History]![cmbCat]) Is Null)) OR (((Product.[Electronic Product Code]) Like "*" & [forms]![Search History]![tbxEPC] & "*") AND ((Product.[Item Name]) Like "*" & [forms]![Search History]![tbxProductName] & "*") AND (([forms]![Search History]![cmbCat]) Is Not Null) AND ((Category.[Parent - Category])=[forms]![Search History]![cmbCat]));</pre>

        1 Reply Last reply
        0
        • V veon cheng

          Good day, I have some problem with my SQL Commands in access, really hope that you can help me out. Category

          CatID Category Name Sub- Category Description

          1 Beverages 123
          2 Condiments 456
          3 Juice 1 help
          4 Coffee 1 pls

          I wanted to display the main category of the Juice which is beverage. No matter how hard i tried, i can't display the Main category in access. Really hope if any kind soul could help me with this Regards Veon

          I Offline
          I Offline
          Ingo
          wrote on last edited by
          #4

          veon cheng wrote:

          I wanted to display the main category of the Juice which is beverage. No matter how hard i tried, i can't display the Main category in access.

          SELECT a.CategoryName FROM Category a INNER JOIN Category b On a.CatId = b.SubId WHERE b.SubCategory = 'Juice';

          ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups