•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 423,608 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,277 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 802 | Replies: 0
![]() |
•
•
Join Date: May 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
I have been trying to see how it is possible to get the name of the primary key column from the database by checking the constraint name. I have, up until now been unsuccessful. I have tried the below and I get nothing returned and no errors as well. Also, I am trying to find out how the code would differ for the foreign key.
By the way this is to be used in PHP so it should be able to return the results with no problem in PHP 4/5
Thanks
I have been trying to see how it is possible to get the name of the primary key column from the database by checking the constraint name. I have, up until now been unsuccessful. I have tried the below and I get nothing returned and no errors as well. Also, I am trying to find out how the code would differ for the foreign key.
By the way this is to be used in PHP so it should be able to return the results with no problem in PHP 4/5
Thanks
$query="SELECT COLUMN_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name='".$tablename."' AND CONSTRAINT_NAME='PRIMARY'";
![]() |
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Help with fixing my source code (C++)
- phpmyadmin help (PHP)
- Help on General Best Practices for Table/Database Design (Database Design)
- Help with database (C#)
- Tell us about yourself! (Community Introductions)
- Dictionary Keys (Python)
- October 2004 - Mathematics: In Depth (Software Development Job Offers)
- Primary Key Issue (Visual Basic 4 / 5 / 6)
Other Threads in the MySQL Forum
- Previous Thread: deploying my sql .......
- Next Thread: Trying to use LIKE statement on JOIN query


Linear Mode