MySql variable ? please.
Firefox Wins Offline
Member
***
Posts: 164
Joined: Mar 2008
Post: #1
MySql variable ? please.
Simple way (without details)
In a MySql table is it possible to use the value of a field as part of the default value of another field?  Biggrin
^^^

OK, here is exactly what I'm looking to do:
1) `my_link` is a new field added to `mybb_forums` table
2) A sample entry is,

Code:
<a href="http://example.com/bb/forumdisplay.php?fid=2">Go To Sample Forum</a>

so when this field (from the row with fid=2) is retrieved, there is a link created to the forum w/ fid=2.**

3a) What is the best (automated) way to create the entries into this field?
3b) I know how to do it with php, but I'm looking for something more "direct."

Edit:
These next sections (below) "probably will not work",
http://dev.mysql.com/doc/refman/5.0/en/d...http://dev.mysql.com/doc/refman/5.0/en/data-type-def
is there a way to do something similar?


3c) If the default value of the field is set to (for example),

Code:
<a href="http://example.com/bb/forumdisplay.php?fid=%fid%">Go To Sample Forum</a>

(or something similar)
3d) Will MySql 'retrieve' this value %fid% (or whatever format will work), from the (newly created) 'fid' field and use that value in the `linkto` field (in the "default sample code?")

  • Like in an Excel spreadsheet, how do I "grab" a value from a different column in the same row?

Searching Google for "MySql variable" mostly gives results related to variables used in queries, and / or user defined "session" variables.

A) How can I use a variable (based on a field value) directly in a MySql table?
and
B) Can the same method work as part of a default value? (Probably not)

Thank you very much


...

..

.
**ps. I do know:
Normally this code (for example)

Code:
<a href="http://example.com/bb/forumdisplay.php?fid=2">Go To Sample Forum</a>

could easily be created "on the fly", but I have a situation where it would be really useful to pull the above example straight out of the db.

(This post was last modified: 09-09-2010 08:05 AM by Firefox Wins.)
09-08-2010 06:49 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
MySql variable ? please. - Firefox Wins - 09-08-2010 06:49 PM
RE: MySql variable ? please. - ZiNgA BuRgA - 09-08-2010, 07:53 PM
RE: MySql variable ? please. - ZiNgA BuRgA - 09-08-2010, 09:19 PM

 Standard Tools
Forum Jump: