Best way to add a column in mysql query
Translations
Englishالعربية
български
català
中文
čeština
dansk
Nederlands
eesti
suomi
français
Deutsch
Ελληνικά
עברית
हिंदी
magyar
Bahasa Indonesia
italiano
日本語
한국어
latviešu
lietuvių
norsk
polski
Português
română
русский
slovenčina
slovenski
español
svenska
ไทย
Türkçe
українська
Tiếng Việt
Can any one please let me know that, I need to add a column dynamically when executing mysql query
Table: Table1
--------------------------
col1 col2 col3
--------------------------
Test OK Test3
Test OK Test5
Test OK Test6
from the above example i need to introduce "col2" as new column and its value to be as "OK"
This question and answers originated from www.stackoverflow.com
Question by VAC-Prabhu (5/14/2010 11:15:52 AM)
Answer |
select a constant value and give it an alias.
SELECT `col1`, 'OK' AS `col2`, `col3`
FROM `table1`
but why do you need to do this in mysql? if the value is the same for every row, you can just as easy add it in your client (php or similar) code
Answer by knittl
Find More Answers