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. General Programming
  3. C#
  4. SQL Script

SQL Script

Scheduled Pinned Locked Moved C#
databasetoolsquestion
17 Posts 7 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.
  • K kibromg

    Hi Guys, I have a table that contains 100 disticnt record.(Table1) I have a second table that contain 40 records(Table2). when i run a script to get me a records that are in Table1 not in Table2. Select * from Table1 where field1 not in (select field1 from Table2) I should have at least 60 records.However ,it doesnot return anything? Can you please advice? Thank you very much.

    D Offline
    D Offline
    Dino Mulahusic
    wrote on last edited by
    #3

    and where does this happens: in code or in database if it is in code try running it in some plsql developer and see what you get

    K 1 Reply Last reply
    0
    • T tom572007

      Could we have the descrition of the 2 tables

      K Offline
      K Offline
      kibromg
      wrote on last edited by
      #4

      Many thanks for your reply.Its Much appreciated Table1 id int Cli Nvarchar(200) Timestamp datetime 100 records Table2 id int Cli nvarchar(200) 40 records Select distinct(cli) from Table1 where Cli not in (select Cli from table2) This should at least return 60 records. Regards Select

      K S 2 Replies Last reply
      0
      • D Dino Mulahusic

        and where does this happens: in code or in database if it is in code try running it in some plsql developer and see what you get

        K Offline
        K Offline
        kibromg
        wrote on last edited by
        #5

        Thanks very much for your reply.It runs on a database.

        D 1 Reply Last reply
        0
        • K kibromg

          Thanks very much for your reply.It runs on a database.

          D Offline
          D Offline
          Dino Mulahusic
          wrote on last edited by
          #6

          Select distinct(cli) from Table1 where cli not in (select Cli from table2) try this with small c in second cli :)

          K 1 Reply Last reply
          0
          • D Dino Mulahusic

            Select distinct(cli) from Table1 where cli not in (select Cli from table2) try this with small c in second cli :)

            K Offline
            K Offline
            kibromg
            wrote on last edited by
            #7

            Still the same.I have tried that also.

            A A 2 Replies Last reply
            0
            • K kibromg

              Many thanks for your reply.Its Much appreciated Table1 id int Cli Nvarchar(200) Timestamp datetime 100 records Table2 id int Cli nvarchar(200) 40 records Select distinct(cli) from Table1 where Cli not in (select Cli from table2) This should at least return 60 records. Regards Select

              K Offline
              K Offline
              kibromg
              wrote on last edited by
              #8

              Any Luck?

              1 Reply Last reply
              0
              • K kibromg

                Still the same.I have tried that also.

                A Offline
                A Offline
                Ashfield
                wrote on last edited by
                #9

                Have you got nulls in your fields? That would cause it.

                Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

                K 1 Reply Last reply
                0
                • K kibromg

                  Still the same.I have tried that also.

                  A Offline
                  A Offline
                  a hamidy
                  wrote on last edited by
                  #10

                  this can help select table1.cli from table1 left join table2 on table1.cli=table2.cli where table2.cli is null

                  1 Reply Last reply
                  0
                  • K kibromg

                    Hi Guys, I have a table that contains 100 disticnt record.(Table1) I have a second table that contain 40 records(Table2). when i run a script to get me a records that are in Table1 not in Table2. Select * from Table1 where field1 not in (select field1 from Table2) I should have at least 60 records.However ,it doesnot return anything? Can you please advice? Thank you very much.

                    C Offline
                    C Offline
                    Christian Graus
                    wrote on last edited by
                    #11

                    This is a SQL question. I would suggest you break it down to try to work out why it doesn't work.

                    Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

                    K 2 Replies Last reply
                    0
                    • A Ashfield

                      Have you got nulls in your fields? That would cause it.

                      Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

                      K Offline
                      K Offline
                      kibromg
                      wrote on last edited by
                      #12

                      Yes Please.when i select distinct(cli) there is one record NULL. When i try to remove it delete from Table1 where cli like NULL it does nothing. Can you please advice how can i remove it?

                      A 1 Reply Last reply
                      0
                      • C Christian Graus

                        This is a SQL question. I would suggest you break it down to try to work out why it doesn't work.

                        Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

                        K Offline
                        K Offline
                        kibromg
                        wrote on last edited by
                        #13

                        Yes Please.when i select distinct(cli) there is one record NULL together with other records When i try to remove it delete from Table1 where cli like NULL it does nothing. Can you please advice how can i remove it?

                        1 Reply Last reply
                        0
                        • C Christian Graus

                          This is a SQL question. I would suggest you break it down to try to work out why it doesn't work.

                          Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

                          K Offline
                          K Offline
                          kibromg
                          wrote on last edited by
                          #14

                          Hi Christian, Can you help me with a script on how to check and remove any Null script from a table. Many thanks

                          T 1 Reply Last reply
                          0
                          • K kibromg

                            Hi Christian, Can you help me with a script on how to check and remove any Null script from a table. Many thanks

                            T Offline
                            T Offline
                            tom572007
                            wrote on last edited by
                            #15

                            You should try IS NULL instead of LIKE NULL

                            1 Reply Last reply
                            0
                            • K kibromg

                              Many thanks for your reply.Its Much appreciated Table1 id int Cli Nvarchar(200) Timestamp datetime 100 records Table2 id int Cli nvarchar(200) 40 records Select distinct(cli) from Table1 where Cli not in (select Cli from table2) This should at least return 60 records. Regards Select

                              S Offline
                              S Offline
                              Skymir
                              wrote on last edited by
                              #16

                              <blockquote class="FQ"><div class="FQA">kibromg wrote:</div>Select distinct(cli) from Table1 where Cli not in (select Cli from table2)</blockquote> Select distinct(cli) from Table1 where Cli not in (select Cli from table2 where Cli is not null) FTFY, SQL server has some floopy processing when it does 'not in' queries.

                              The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.

                              1 Reply Last reply
                              0
                              • K kibromg

                                Yes Please.when i select distinct(cli) there is one record NULL. When i try to remove it delete from Table1 where cli like NULL it does nothing. Can you please advice how can i remove it?

                                A Offline
                                A Offline
                                Ashfield
                                wrote on last edited by
                                #17

                                You cannot do like null (or = null either), you have to do where cli is not null (or cli is null depending on whic you want)

                                Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP

                                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