Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

query to query

Guest
Dec 19, 2013 Dec 19, 2013

it is more complicate to describe why i have to do this but it's the only way just an example below.

My query to give me anthing from the table when i do the query to query to get what i want but when i use the left string function then i got an error below.

Query Of Queries syntax error.

Encountered "left. Incorrect conditional expression, Expected one of [like|null|between|in|comparison] condition,

thanks

<cfquery name="type" datasource="#dsn#">

select * from [dbo].[requestType]

</cfquery>

results look like

type:

=====

ADD

REMYU

RECD

I want to do the query to query to get the REMYU

<cfquery name="find" dbtype="query">

select * from type

where left(type,3) = 'rem'

</cfquery>

<cfdump var="#find#">

748
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 19, 2013 Dec 19, 2013

The left() function is typically a SQL function, and is not available in Query-of-Query syntax.  You could rewrite your first query to be more specific:

<cfquery name="type" datasource="#dsn#">

select * from [dbo].[requestType]

where left(type,3) = 'rem'

</cfquery>

Otherwise, you could use the LIKE operator instead:

<cfquery name="find" dbtype="query">

select * from type

where type LIKE 'rem%'

</cfquery>

-Carl V.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 19, 2013 Dec 19, 2013

sorry it was mistype, it suppose to be where left(type,3) != 'rem'

then how can i peform the like fc

<cfquery name="find" dbtype="query">

select * from type

where type NOT  LIKE 'rem%' ??

</cfquery>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 19, 2013 Dec 19, 2013

Yes, NOT LIKE should work.

-Carl V.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 19, 2013 Dec 19, 2013
LATEST

thank you,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources