SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: Unique Keys & Inserting Dates
-
Sep 3, 2000, 08:36 #1
- Join Date
- Jul 2000
- Posts
- 88
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Question 1: HOw can I avoid adding duplicate entries. I was reading something about a unique constraint but found out that mySQL does not support that. I already have another column as my primary key. If I make the "Business Name" the primary key, will this avoid duplicate entries with the same business name? How can I add or change the primary key on existing columns?
Question 2: I am trying to insert the expiration date when the business listing is submitted from my PHP3 pages. I was trying the current date function + an INTERVAL. But nothing was being inserted into my mySQL database column....
This is what I was inserting into my PHP 3 page:
"Expiration_Date=CURDATE(), INTERVAL 6 MONTH)";
I also tried many variations, and nothing worked...I know you can do this for Select queries, but can you use this method for INSERT?
-
Sep 5, 2000, 08:55 #2
- Join Date
- Apr 2000
- Location
- Melbourne, Australia
- Posts
- 2,571
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
HOw can I avoid adding duplicate entries.
Code:mysql> CREATE UNIQUE INDEX index_name --> ON tbl_name (col_name);
I am trying to insert the expiration date ...
Code:"Expiration_Date=ADDDATE(CURDATE(), INTERVAL 6 MONTH)";
Kevin Yank
CTO, sitepoint.com
I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
Baby’s got back—a hard back, that is: The Ultimate CSS Reference
Bookmarks