Results 1 to 5 of 5

Thread: SQL Statement Error

  1. #1
    Join Date
    Jun 2003
    Posts
    17

    Unhappy SQL Statement Error

    Hello Members, I am currently having problem in Access relationship table coding. Ok this is how my Database it is:

    FirstDB(ID,UserID,FirstName,LastName,Title,Nick)
    SecondDB(ID,Company,Address,City)

    That is sample of DB. The ID column is AUTONUMBER FIELD type. So The FirstDB --> ID is our Primary Key and SecondDB-->ID is our Foreign Key which is LONG INTEGER FIELD type. The Both Primary and Foreign Key are already set Enforce Referential Integrity. Ok now I am going to add new data to UserID,FirstName,LastName,Title,and Nick column. So I use like this :

    INSERT INTO FirstDB(UserID,FirstName,LastName,Title,Nick) VALUES (‘mugun’,’xmen’,’two’,’Mr’,’Xmen ’)

    The above statement already adds our new data to FirstDB Table. But what I want it is, I am going to add more info about Company, Address and City based on that contact in SecondDB Table. How should I can do that? Please guide me as soon as possible. Thanx In Advanced.

    -mugun

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    INSERT INTO SecondDB(ID,Address,city,company)
    values (IDOFFIRSTDB,'aaaa','ssss','dddd')

  3. #3
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    you can get the ID by using

    select id from firstdb where userid ='xtwo'

  4. #4
    Join Date
    Jun 2003
    Posts
    17

    Smile Thanx Sir

    Thanx for replying sir. But the UserID field are set index as Duplicate(Yes). So it can be repeated duplicate data of UserID will found in firstDB. Actually sir, this is AddressBook system Database. So let we think that ONE User CAN HAVE a lot of ADDRESS. So you have any solution.
    Thanx in advanced.

  5. #5
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    In that case put get ID as

    select id from firstdb
    where UserID = 'mugun'
    and FirstName = 'xmen'
    and LastName = 'two'
    and Title = 'Mr'
    and Nick = 'Xmen';

Posting Permissions

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