Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want to fetch first 9 numbers from matching with other column please help me to find out thank you....?
SQL
SELECT  MAINFILE.facno,GLMAST.fglhead
FROM    MAINFILE INNER JOIN GLMAST
    ON  LEFT(MAINFILE.facno,9) like GLMAST.fglcode
    AND GLMAST.fglhead='" & ComboBox2.Text & "' "
Posted
Updated 12-Nov-14 20:05pm
v2
Comments
Sanchayeeta 13-Nov-14 0:59am    
Can you please provide your table structure.
lakshjoshi 13-Nov-14 1:07am    
i mathcing glcode='010000101' with facno='010000101000001' where i want to select frist 9 numbers to match with glcode from facno...i hope my concept understood..
Jörgen Andersson 13-Nov-14 2:08am    
You're wide open to SQL Injection, please change your query to use parameters.
Obligatory XKCD reference: http://xkcd.com/327/
Jörgen Andersson 13-Nov-14 2:15am    
Is fglcode always 9 numbers?
lakshjoshi 13-Nov-14 2:19am    
yes...

Like Shweta has already commented, I also don't see an immediate reason to why it shouldn't work.
So please update your question with what problem you're getting.
Meanwhile you can try this:
SQL
SELECT  MAINFILE.facno,GLMAST.fglhead
FROM    MAINFILE INNER JOIN GLMAST
    ON  MAINFILE.facno like GLMAST.fglcode + '%'
    AND GLMAST.fglhead='" & ComboBox2.Text & "' "
 
Share this answer
 
try this
SQL
SELECT Top 9 MAINFILE.facno,GLMAST.fglhead
FROM    MAINFILE INNER JOIN GLMAST
    ON  LEFT(MAINFILE.facno,9) like GLMAST.fglcode
    AND GLMAST.fglhead='" & ComboBox2.Text & "' "
ORDER BY MAINFILE.facno
 
Share this answer
 
yes its works thank to all....

SELECT DISTINCT GLMAST.fglcode,GLMAST.fglhead FROM MAINFILE INNER JOIN GLMAST ON LEFT(MAINFILE.facno,9) like GLMAST.fglcode AND GLMAST.fglhead = '" & ComboBox2.Text & "' "
 
Share this answer
 
thank you all..problem solved
SQL
"SELECT  DISTINCT GLMAST.fglcode,GLMAST.fglhead FROM MAINFILE INNER JOIN GLMAST ON  LEFT(MAINFILE.facno,9) like GLMAST.fglcode AND GLMAST.fglhead = '" & ComboBox2.Text & "'  "
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900