5

i have the following sql select query

select column1,column2 from mytable

is a way to add an empty column to the query that doesnt exist in the table such as

select column1,column2,empty int column from mytable

2 Answers 2

5

You can do this like that

select column1,column2,1 as column3 from mytable
Sign up to request clarification or add additional context in comments.

4 Comments

but how do i specify the type?
for c# application, inside the property setter i want to do somthing like _suppno = value ?? int.Parse(DateTime.Now.ToString("ddMMyy") + supplierid); , its more of adding the columns to the datatable rather than having to add them in code
If you need integer just remove quotes from my query. It will be: select column1,column2,1 as column3 from mytable
null is unknown type, use number if you want integer
-1

w3 Schools has a good section on this SQL Alter Table Statement.

The specific command would ALTER TABLE table_name ADD column_name datatype

While it does not add the column in a select statement I believe this will accomplish what you are looking for.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.