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
Cannot capture date-time in a Unix ksh script
Outlook 2007 - fails to open correctly
usb devices causes system to reboot
Outlook - Display Format Problem
Vista PaperPort Installation Errors
How Do I Shorten Code in Q language?
Is there a way to send a meeting request in Outlook 2007 in BCC?
Grant a single account access to all mailboxes in Exchange 2003
Cannot view public folders in Exchange 2007 powershell.
Creating a bash script which accepts parameters