-
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
-
INSERT INTO SecondDB(ID,Address,city,company)
values (IDOFFIRSTDB,'aaaa','ssss','dddd')
-
you can get the ID by using
select id from firstdb where userid ='xtwo'
-
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.
-
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
-
Forum Rules
|
|