how to set Foreign Key in database? mariadb
Discussion posts and replies are publicly visible
Using alter command!!www.w3schools.com/.../sql_foreignkey.asp
table1
table 2
based on the above two tables tabel1 & table 2 ,I want claim id is foreign key in the table 2 ? what is the syntax ?
Did you check the link I provided in the above comment?
yea I checked bro ,& use different types of commends but not get my problem, error coming
ALTER TABLE LMS_AprrovalsADD FOREIGN KEY (Claim ID) REFERENCES lmscustomerdetails(id);
SQL query: Copy
ALTER TABLE LMS_Aprrovals ADD FOREIGN KEY (Claim ID) REFERENCES lmscustomerdetails(id);
MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID) REFERENCES lmscustomerdetails(id)' at line 2
ALTER TABLE LMS_Aprrovals ADD CONSTRAINT fk_claimtype, ADD FOREIGN KEY (Claim ID) REFERENCES lmscustomerdetails(id);
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ADD FOREIGN KEY (Claim ID) REFERENCES lmscustomerdetails(id)' at line 2
ALTER TABLE LMS_Aprrovals ADD CONSTRAINT my_fk_type, ADD FOREIGN KEY (Claim ID) REFERENCES lmscustomerdetails(id);
1 2
that's ok bro I got it & one more thing how to delete a unnecessary or useless table (entire table)in mariaDB