how to set Foreign Key in database? mariadb
Discussion posts and replies are publicly visible
ALTER TABLE table2ADD FOREIGN KEY (Claim ID) REFERENCES table1(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
Try removing the space between Claim and ID in your column name by renaming the column name of 2nd table and try again with same syntax to add foreign key.
Refer this link for better understanding..
https://www.sqlshack.com/how-to-write-sql-queries-with-spaces-in-column-names/
ok bro i will do
yea i got it bro thanks....