Microsoft
Software
Hardware
Network
Question : MySQL create table question ........ default value for a field
Hi guys hope u are all well and can help me with a create table question for MySQL.
Here is my current create table design....................
..........
..........
..........
...
CREATE TABLE subiframes_sif (
id_sif int(11) NOT NULL auto_increment,
url_sif varchar(255) NOT NULL,
subiframeurl_sif varchar(255) NOT NULL,
code_sif text,
description_sif text,
PRIMARY KEY (id_sif),
UNIQUE KEY url_sif (url_sif)
)
--------------------------
----------
----------
----------
----------
----------
----------
----------
---
If I do a select all on this table, it looks like the following.................
..........
.......
select id_sif, url_sif from subiframes_sif;
id_sif url_sif subiframeurl_sif
--------------------------
----------
----------
----------
----------
----------
----------
----------
----
1 menu2_sandbox1_example.php
############
WHAT ID LIKE:
############
Id like the value for column subiframeurl_sif to be autopopulated, like a default so to speak, by doing the following....
1) Look at the corresponding value of the column url_sif
2) Grab this value, and strip off the .php in its name
3) Append a '_subiframe.php' to the value that is left after step 2)
4) Insert this value from step 3) into the field for subiframeurl_sif
##########
EXAMPLE:
##########
id_sif url_sif subiframeurl_sif
--------------------------
----------
----------
----------
----------
----------
----------
----------
----
1 menu2_sandbox1_example.php
In the above, the value for row 1 in column subiframeurl_sif would be:
menu2_sandbox1_example_sub
iframe.php
So,
select id_sif, url_sif from subiframes_sif; would result in:
id_sif url_sif subiframeurl_sif
--------------------------
----------
----------
----------
----------
----------
----------
----------
----
1 menu2_sandbox1_example.php
menu2_sandbox1_example_sub
iframe.php
Id like this done on my create table design, so that this would be the default value for subiframeurl_sif for any new records inserted
Any help greatly appreciated. :>)
Answer : MySQL create table question ........ default value for a field
update TABLE set subiframeurl_sif=replace(u
rl_sif ,'.php','_subiframe.php')
Random Solutions
Script to delete folders which are 30 days older than current date
Share outlook 2007 contacts items and sync it to personal contact under exchange server
How do I prevent Blue Screen most likely being caused by nvidia Drivers?
Outlook 2003 signatures - where are these files stored? I want to transfer some from one PC to another.
Transferring 'MyFavorites"
C:\windows is 46 GB big ? HELP
Outlook Calendar invitations auto forwarding to another user email
Intermit problems: Windows Explorer looks weird and new tasks won't start
IMAP on Exchange Server SBS 2003 keeps getting a 'connection refused' error message
Overwriting Hosts file in Vista