SQL Server Mobile subquery allowed?
I apologize if this is the wrong forum, but I cannot find a forum dedicated to SQLServer Mobile...
My question is whether or not subqueries are allowed in SQL statements in SQL Sever Mobile. For example:
select
a.Id, a.DefaultDescription,(select b.Categoryfrom OldvListItem bwhere b.Description= a.DefaultDescription) Categoryfrom ListItem aThis is giving me the following error: ....Token in error = selectIs this a limitation of SQL Server Mobile? Or am I doing something stupid? I would like to use subqueries in INSERT and UPDATE statements too...Thanks,
Chris
[1455 byte] By [
ChrisD] at [2007-12-16]
Why don't you simply unwrap the query?
select a.Id, a.DefaultDescription, b.Category Category from ListItem a INNER JOIN OldvListItem b ON b.Description = a.DefaultDescriptionOne other thing to keep in mind - try to avoid linking tables on the string coulmn. Use IDs where possible
Thank you for your reply. I guess my example was a little simplistic and an inner join works well in that case.
I'm guessing from your answer that subqueries are not allowed in SQL Mobile. But how about an UPDATE statement? Let's say I need to update a column in table A with data from table B?
TableA:
Id
DescriptionId
BlankColumn
TableB:
Id
Description
UPDATE TableA a SET BlankColumn = (SELECT b.Description FROM TableB b
WHERE b.Id = a.DescriptionId)
Is this type of subquery possible (it doesn't seem to work...same error)? How else would I get data from another table in an update statement? (Actually, this is largely an acedemic question now; I've already gone and wrote a VB.NET routine to solve the problem).
(BTW: I'm dealing with legacy data that eschewed artifical keys, and I'm trying to copy this data into tables with ID key columns...hence the need for the above statements)
Thanks Again,
Chris
ChrisD,
Did you ever get an answer on this post? I'm running into the same problem with trying to use a subquery in my SQL Server Mobile Edition.
Are they allowed? If so, is there some special syntax I need to use?
Thanks