Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5933389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:58:01+00:00 2026-05-22T14:58:01+00:00

I have the next query: SELECT c.client_code, a.account_num, m.account_close_date, u.uso, m.product_name FROM accounts a

  • 0

I have the next query:

SELECT c.client_code, a.account_num, m.account_close_date, u.uso, m.product_name
FROM accounts a INNER JOIN Clients c ON c.id = a.client_id INNER JOIN 
    Uso u ON c.uso_id = u.uso_id INNER JOIN Magazine m ON a.account_id = m.account_id 

and I need to compare product_name with input parameter.

product_name and input parameter @s are comma-delimited strings.
I use next split function:

ALTER FUNCTION [dbo].[Split] 
(   
    @s VARCHAR(max),
    @split CHAR(1)
)
RETURNS @temptable TABLE (items VARCHAR(MAX))    
AS
BEGIN

DECLARE @x XML

    SELECT @x = CONVERT(xml,'<root><s>' + REPLACE(@s,@split,'</s><s>') + '</s></root>');

    INSERT INTO @temptable          
        SELECT [Value] = T.c.value('.','varchar(20)')
        FROM @X.nodes('/root/s') T(c);
RETURN
END;

I think that I need to check the intersection of tables, which I will receive after split of product_name and after split of input parameter. I trid to do this:

WHERE (select * from dbo.Split(m.product_name, ';') 
INTERSECT select * from dbo.Split('product1;product2',';')) 
is not null

But it does not work quite right. Please, help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:58:01+00:00Added an answer on May 22, 2026 at 2:58 pm

    INTERSECT requires the same column output and is used like UNION or EXCEPT: not in the WHERE clause

    Just JOIN onto the udf

    ...
    INNER JOIN
    Magazine m ON a.account_id = m.account_id
    INNER JOIN
    dbo.Split(@parameter, ';') CSV ON m.productname = CSV.items
    

    If you need to split m.productname, if you can’t fix the design, use CROSS APPLY

    ...
    INNER JOIN
    Magazine m ON a.account_id = m.account_id
    CROSS APPLY
    dbo.Split(m.productname, ';') WTF
    INNER JOIN
    dbo.Split(@parameter, ';') CSV ON WTF.items = CSV.items
    

    However, JOIN and INTERSECT give different results if @parameter has duplicated values. Add a DISTINCT to the UDF for example to get around this. Or change the udf JOIN into EXISTS

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the next mysql query: $productn = $jdb->query('SELECT t2.title FROM '.DB_PREFIX.'shopping_cart AS t1
i have the next query: select avHours, date_add('2010-01-20', Interval 2 DAY) from tbl_available order
I have the following MySQL query: SELECT pool.username FROM pool LEFT JOIN sent ON
I have the next query: var bPermisos = from b in ruc.Permisos where b.IdUsuario
I have the following query: SELECT AccountNumber, RptPeriod FROM dbo.Report ORDER BY AccountNumber, RptPeriod.
This is kinda weird. I have the next query: SELECT * , GROUP_CONCAT( x.tag
I have: remoteDB(); QSqlQuery query(SELECT * FROM products); int id = query.record().indexOf(id); int aa
I have a Recordset obtained by the following query: SELECT DISTINCT [Number] FROM NUMBERS
I have MYSQL query SELECT WEEKDAY(CreatedDate), COUNT(CreatedDate), CreatedDate FROM bug_List GROUP BY WEEKDAY(CreatedDate) But
I have the next query that I run via SQLCMD.EXE use [AxDWH_Central_Reporting] GO EXEC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.