Jump to content

Simple Sql Query Doubt


tejak123

Recommended Posts

this was the same argument that came up last week with an architect..I defended it saying both are same performance(and its true they are same at least it is justified based on the execution plan) but it is advisable because its more clear to the second eye what the intention is and sometimes not in works weirdly based on the column property..grammar thapul unte kshminchu asal ardam lekunte marninchu

 

grammar tappul vethikentha matter ledu le mayya naa daggara,,,,,,, cheers  photo-thumb-29519.jpg?_r=1366161420

Link to comment
Share on other sites

  • Replies 67
  • Created
  • Last Reply

Top Posters In This Topic

  • tejak123

    16

  • puli_keka

    12

  • JollyBoy

    11

  • SUbba LIngam

    10

Popular Days

Top Posters In This Topic

select a.* from table a where LENGTH(REPLACE(TRANSLATE(a.PRODUCT_BOUGHT_CATEGORY,
’0123456789′, ‘a’), ‘a’, NULL)) > 0 and not exists ( select 'x' from table b where a.user=b.user and
 LENGTH(REPLACE(TRANSLATE(b.PRODUCT_BOUGHT_CATEGORY,
’0123456789′, ‘a’), ‘a’, NULL)) <= 0 )
 
 
idi try chesi cheppu vay, maa maanana memu kottinchukuntunnam kani nuvvu matram em cheppatle
Link to comment
Share on other sites

select a.* from table a where LENGTH(REPLACE(TRANSLATE(a.PRODUCT_BOUGHT_CATEGORY,
’0123456789′, ‘a’), ‘a’, NULL)) <= 0 and exists 
 ( select 'x' from table b where a.user=b.user and
 LENGTH(REPLACE(TRANSLATE(b.PRODUCT_BOUGHT_CATEGORY,
’0123456789′, ‘a’), ‘a’, NULL)) > 0 )
.//
 
 
Chesthunna bhaiya.. i am 100 times more tensed.. first job bhaiya.. koppadaku
Link to comment
Share on other sites

edhi correct ye kada va its working I tried

 

SELECT * FROM UserProduct WHERE PRODUCT NOT LIKE '%[0-9]%'

correste...aithe this works....

 

 

select  distinct  USER  from table_name

where  PRODUCT_BOUGHT_CATEGORY  not like   '%[0-9]%' 

 

Link to comment
Share on other sites

 

select a.* from table a where LENGTH(REPLACE(TRANSLATE(a.PRODUCT_BOUGHT_CATEGORY,
’0123456789′, ‘a’), ‘a’, NULL)) <= 0 and exists 
 ( select 'x' from table b where a.user=b.user and
 LENGTH(REPLACE(TRANSLATE(b.PRODUCT_BOUGHT_CATEGORY,
’0123456789′, ‘a’), ‘a’, NULL)) > 0 )
.//
 
 
Chesthunna bhaiya.. i am 100 times more tensed.. first job bhaiya.. koppadaku

 

 

kopam endi va.. em using SQL ki

Link to comment
Share on other sites

annay nenu sarigga substitute cheyyalekunna values..

 

select a.* from table a where LENGTH(REPLACE(TRANSLATE(a.PRODUCT_BOUGHT_CATEGORY,
’0123456789′, ‘a’), ‘a’, NULL)) <= 0 and exists 
 ( select 'x' from table b where a.user=b.user and
 LENGTH(REPLACE(TRANSLATE(b.PRODUCT_BOUGHT_CATEGORY,
’0123456789′, ‘a’), ‘a’, NULL)) > 0 )
.//
 
 
Chesthunna bhaiya.. i am 100 times more tensed.. first job bhaiya.. koppadaku

 

Link to comment
Share on other sites

error vasthundhi bhaiya

 

user anedhi nee column name aithe   [USER]  ivvu ..user anedhi reserved keyword..  error emi vasthundo vey ikkada

Link to comment
Share on other sites

SELECT DISTINCT [USER]
FROM Products
WHERE [USER] NOT IN (
        SELECT DISTINCT [USER]
        FROM Products
        WHERE PRODUCT_BOUGHT_CATEGORY LIKE '%[0-9]%'
        )

idhi work aithe we can see performance improvements.. 

Link to comment
Share on other sites

DECLARE @t TABLE (userid CHAR(1),prod_category VARCHAR(15))
INSERT @t
SELECT 'A','YUI'
UNION ALL
SELECT 'B','JHI'
UNION ALL
SELECT 'C','WER'
UNION ALL
SELECT 'E','123'
UNION ALL
SELECT 'A','456'
UNION ALL
SELECT 'C','DFG'
UNION ALL
SELECT 'B','CFT'
UNION ALL
SELECT 'E','365'
UNION ALL
SELECT 'S','ASD'
UNION ALL
SELECT 'H','HJK'
UNION ALL
SELECT 'E','ASD'
 
 
SELECT DISTINCT userid FROM @t
WHERE userid NOT IN(
SELECT DISTINCT userid FROM @t
WHERE ISNUMERIC(prod_category)=1
)
AND ISNUMERIC(prod_category)!=1
Link to comment
Share on other sites

×
×
  • Create New...