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
Foreign Keys
AT command time = remote machine current time
ADSI Script problem : How do I access/modify objects in different domain ?
Additional help with my batch script to check a file's date prior to sending...
Why am I getting Msg 245 for this:
SMART HD Imminent Failure Message - Believable?
Removing plus "+" sign from Dynamic Google Adwords in url
SMTP connect failed to exchange server 2007
Trying to load ghost client with a boot CD(pcdos) created with ghost boot wizard, system is erroring out with unable to load OS.
What is "generic pup.g" ?