I have two database tables which I use to feed the same jquery DataTable. The problem is that the data is very similar (I show information for individual persons and companies) but it differs in that that the individual person has Personal Identification Number(PIN) and the Company has (IBAN). So I need two columns in my jquery DataTable one named PIN and one named IBAN and each row will have only one of the both field filled and the other will be empty.
So my problem is, due to the fact how I construct my JSON the most easiest way would be to add some fake column to each query like, for the Individual Perosn query :
SELECT Name, City, PIN, IBAN(this is the fake column which should be null) FROM Persons
and for the Company query :
SELECT Name, City, PIN(this time this is a fake column which should be null), IBAN FROM Companies
The problem is that I don't know if this is possible, and if it is, how to do it. I have the option to do this later after I fetch the records but like this it would be very easy.
You can select a fake column quite easily. Just create the value and name it.
SELECT Column1, Column2, '' AS FakeColumn, Column3 FROM MyTable
Or with NULL:
SELECT Column1, Column2, NULL AS FakeColumn, Column3 FROM MyTable
I think you can do it like this
Declare @IBAN nvarchar(10)=NULL
SELECT Name, City, PIN, @IBAN FROM Persons
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With