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. Help with SQL in MS Access

Help with SQL in MS Access

Scheduled Pinned Locked Moved Database
databasehelpsysadminquestion
9 Posts 2 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.
  • X Offline
    X Offline
    xx77abs
    wrote on last edited by
    #1

    Hello ! I'm doing little project and I need database for it, but not whole server. So I choose Access ... But that's pain in the a** :( I have a relatively simply query in which I need to do LEFT JOIN: SELECT a.*, b.* FROM a LEFT JOIN b ON (a.pid = b.pretplatnik_id) AND (a.iid = b.izdanje_id); a and b are booth some other queries. I needed to do this because I can't do query inside a query in access :( And there's problem. It all works, except it shows only data from query a and nothing from query b. Everything from b is NULL. Interesting thing is that if I change part "LEFT JOIN" to "INNER JOIN" it returns booth results from query a and b. So does anyone have an idea why LEFT JOIN isn't working ? Thanks for your time and help :)

    B 1 Reply Last reply
    0
    • X xx77abs

      Hello ! I'm doing little project and I need database for it, but not whole server. So I choose Access ... But that's pain in the a** :( I have a relatively simply query in which I need to do LEFT JOIN: SELECT a.*, b.* FROM a LEFT JOIN b ON (a.pid = b.pretplatnik_id) AND (a.iid = b.izdanje_id); a and b are booth some other queries. I needed to do this because I can't do query inside a query in access :( And there's problem. It all works, except it shows only data from query a and nothing from query b. Everything from b is NULL. Interesting thing is that if I change part "LEFT JOIN" to "INNER JOIN" it returns booth results from query a and b. So does anyone have an idea why LEFT JOIN isn't working ? Thanks for your time and help :)

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      try to use

      LEFT OUTER JOIN


      I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

      X 1 Reply Last reply
      0
      • B Blue_Boy

        try to use

        LEFT OUTER JOIN


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

        X Offline
        X Offline
        xx77abs
        wrote on last edited by
        #3

        Thanks for help :) But it's not working :( Same result as just using "LEFT JOIN"

        B 1 Reply Last reply
        0
        • X xx77abs

          Thanks for help :) But it's not working :( Same result as just using "LEFT JOIN"

          B Offline
          B Offline
          Blue_Boy
          wrote on last edited by
          #4

          Well,if you don't mind then post here some tables data, and result which you want to get and we will try to give you hand on query. :)


          I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

          X 1 Reply Last reply
          0
          • B Blue_Boy

            Well,if you don't mind then post here some tables data, and result which you want to get and we will try to give you hand on query. :)


            I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

            X Offline
            X Offline
            xx77abs
            wrote on last edited by
            #5

            Thanks, but I've solved it :D In b query I've had GROUP BY statement, and it was something like SELECT blabla FROM bla GROUP BY pid, iid; Now I've changed it to SELECT blabla FROM bla GROUP BY iid, pid; and everything works ... Although I don't think there's any difference, but ok ... if there is, please explain it to me :D

            B 1 Reply Last reply
            0
            • X xx77abs

              Thanks, but I've solved it :D In b query I've had GROUP BY statement, and it was something like SELECT blabla FROM bla GROUP BY pid, iid; Now I've changed it to SELECT blabla FROM bla GROUP BY iid, pid; and everything works ... Although I don't think there's any difference, but ok ... if there is, please explain it to me :D

              B Offline
              B Offline
              Blue_Boy
              wrote on last edited by
              #6

              It's possible to use DISTINCT instead of GROUP BY but when you had solution then let it as it is.


              I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

              X 1 Reply Last reply
              0
              • B Blue_Boy

                It's possible to use DISTINCT instead of GROUP BY but when you had solution then let it as it is.


                I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

                X Offline
                X Offline
                xx77abs
                wrote on last edited by
                #7

                Yes, but can I use distinct with two fields ? And I also did use SUM with GROUP, I think that I can't use sum with distinct ...

                B 1 Reply Last reply
                0
                • X xx77abs

                  Yes, but can I use distinct with two fields ? And I also did use SUM with GROUP, I think that I can't use sum with distinct ...

                  B Offline
                  B Offline
                  Blue_Boy
                  wrote on last edited by
                  #8

                  When you have case to use agregate functions then better use GROUP BY but still you can use DISTINC and with subquery you can get SUM or any else agregate function.


                  I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

                  X 1 Reply Last reply
                  0
                  • B Blue_Boy

                    When you have case to use agregate functions then better use GROUP BY but still you can use DISTINC and with subquery you can get SUM or any else agregate function.


                    I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

                    X Offline
                    X Offline
                    xx77abs
                    wrote on last edited by
                    #9

                    Ok, thanks. It's good to know :)

                    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