How to include many "sub"-queries in a SQL statement to generate file paths for images?
Posted
by Zachary
on Stack Overflow
See other posts from Stack Overflow
or by Zachary
Published on 2010-05-06T22:38:13Z
Indexed on
2010/05/06
22:48 UTC
Read the original article
Hit count: 277
Greetings,
I have three fields in legacy MySQL database/application.
- image_type
- image_of_bush
- image_prefix
I need to extract the data into a full image file path, into a .CSV file, where each combination (mentioned below) is a column. Can it all be done in SQL? Or can you recommend a better way? Currently using PHP to display the combinations on the product page. this is also part of a larger query, which is extracting data from an OS Commerce mySQL database.
CASE ONE
One Horizontal Image
image_type = "Horizontal Image"
image_of_bush = "No Image of Bush"
IMAGE NAME: image_prefix + _s + .jpg (Example: Albertine_s.jpg)
CASE TWO
One Vertical Image
image_type = "Vertical Image"
image_of_bush = "No Image of Bush"
IMAGE NAME: image_prefix + _v + .jpg (Example: Albertine_v.jpg)
CASE THREE
Two Horizontal Images
image_type = "Horizontal Image"
image_of_bush = "Horizontal Image of Bush"
FIRST IMAGE NAME: image_prefix + _s + .jpg (Example: Albertine_s.jpg)
SECOND IMAGE NAME: image_prefix + _bs + .jpg (Example: Albertine_bs.jpg)
CASE FOUR
Two Vertical Images
image_type = "Vertical Image"
image_of_bush = "Vertical Image of Bush"
FIRST IMAGE NAME: image_prefix + _v + .jpg (Example: Albertine_v.jpg)
SECOND IMAGE NAME: image_prefix + _bv + .jpg (Example: Albertine_bv.jpg)
CASE FOUR
One Horizontal and One Vertical Image
image_type = "Horizontal Image"
image_of_bush = "Vertical Image of Bush"
FIRST IMAGE NAME: image_prefix + _s + .jpg (Example: Albertine_s.jpg)
SECOND IMAGE NAME: image_prefix + _bv + .jpg (Example: Albertine_bv.jpg)
CASE FIVE
One Vertical and One Horizontal Image
image_type = "Vertical Image"
image_of_bush = "Horizontal Image of Bush"
FIRST IMAGE NAME: image_prefix + _v + .jpg (Example: Albertine_v.jpg)
SECOND IMAGE NAME: image_prefix + _bs + .jpg (Example: Albertine_bs.jpg)
© Stack Overflow or respective owner