473,320 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Concatenating string to subquery result?

1
I have a few tables tables, one of which has a column which contains part of the name of the other tables.

So basically I am trying to get this half name by running

SELECT subName FROM table_1 WHERE condition

And the result of this would be used in a second query to search for something in the specific table, for example

SELECT TOP 1 * FROM fullTableName ORDER BY someColumn

So by joining the 2 together and assumin the other half of the column name is static I am trying to do this

'SELECT TOP 1 * FROM 'staticName' + (SELECT subName FROM table_1 WHERE someCondition) ORDER BY someColumn

But php keeps giving me
Expand|Select|Wrap|Line Numbers
  1. Description: Incorrect syntax near 'staticName'.
Am I doing something wrong? I am just starting to learn SQL Server and while I could write 2 queries and save the data from the first and use on the second I thought I'd save time and code by nesting the queries which I haven't yet tried.

Best Regards

NooK
Oct 18 '07 #1
0 2302

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Andrew Mayo | last post by:
Here's a really weird one for any SQL Server gurus out there... We have observed (SQL Server 2000) scenarios where a stored procedure which (a) begins a transaction (b) inserts some rows into...
3
by: olanorm | last post by:
I have a query where one or more of the columns returned is a result from a subquery. These columns get their own alias. I want to filter out the rows containing NULL from the subqueries but it...
0
by: Greg Stark | last post by:
Postgresql 7.4b2 (approximately, compiled out of CVS) When I have a subquery that has a complex subquery as one of the result columns, and then that result column is used multiple times in the...
7
by: K. Crothers | last post by:
I administer a mechanical engineering database. I need to build a query which uses the results from a subquery as its input or criterion. I am attempting to find all of the component parts of...
9
by: photomonkey | last post by:
I am having a problem with a relatively simple sql query, and was hoping that somebody could help me on this forum. Basicaly the situation is that I have two tables, a Vendors table (Vendors)...
4
by: Juan | last post by:
Does any one know if there are reported bugs when concatenating strings? When debugging each variable has the correct value but when I try to concatenate them some values are missing (I can´t see...
10
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a...
3
by: TheCoder | last post by:
Why does this work: It seems that we're concatenating two literals: std::cout << greeting + name + " Hello " + "There" << std::endl; but if you remove (greeting + name +), it doesn't work ?
2
ronnil
by: ronnil | last post by:
My database looks like t1 id label t2 id attr_nam attr_val
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.