  | 
              
	              
	                
  
    |   | 
   
  
    
        
        คำสั่ง SQL ที่ตัดข้อมูลที่เราไม่สนใจออก เป็นคำสั่งยังไงค่ะ     | 
   
  
    |   | 
   
 
 
 
	
		
			  | 
	   | 
	    | 
		
			  | 
	 
	
		
			  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                เป็นโปรแกรมรวม Group ให้เข้าพวกเหมือน subset ค่ะ 
ตัวอย่างนะค่ะ คือ ในส่วนของ  Assembly   จะมีข้อมูล แบบนี้ NJ1573-11 แต่ตั้งแต่หลัง - เราจะไม่สนใจสนใจแต่ข้างหน้าอ่าค่ะ 
จะใช้คำสั่งไหนได้ค่ะ 
Code (VB.NET) 
Imports System.Data.Odbc
Imports System.Data
Public Class Form2
    Dim conn As OdbcConnection
    Dim strcon As String
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim conn As OdbcConnection = New OdbcConnection()
        Dim da As OdbcDataAdapter
        Dim ds As DataSet = New DataSet
        Dim strcon As String = "DRIVER={Microsoft Excel Driver (*.xls)}; IMEX=1; HDR=NO;Excel 8.0;ReadOnly=0; DBQ=D:\\nicha\\Model.xls"
        conn = New OdbcConnection(strcon)
        conn.Open()
        Dim strSQL As String
        strSQL = "SELECT [Sheet2$].Customer,Group,[Sheet2$].Assembly,sum(M1),sum(M2),sum(M3) FROM [Sheet1$],[Sheet2$] where [Sheet2$].Assembly = [Sheet1$].Assembly Group by [Sheet2$].Customer,Group,[Sheet2$].Assembly "
        da = New OdbcDataAdapter(strSQL, conn)
        da.Fill(ds)
        DataGridView1.DataSource = ds.Tables(0)
        conn.Close()
        da = New OdbcDataAdapter(strSQL, conn)
        da.Fill(ds)
    End Sub
End Class
 
 
  Tag : - - - -              
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2010-04-30 07:43:24 | 
                      By :
                          nanamashii | 
                      View :
                          1428 | 
                      Reply :
                          4 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  | 
	 
	
		
			  | 
		  | 
		
			  | 
		
			  | 
	 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Example 1: 
 
SELECT SUBSTR(store_name, 3)  
FROM Geography  
WHERE store_name = 'Los Angeles'; 
 
Result: 
 
's Angeles' 
 
Example 2: 
 
SELECT SUBSTR(store_name,2,4)  
FROM Geography  
WHERE store_name = 'San Diego'; 
 
Result: 
 
'an D' 
 
ไปลองใช้ดูครับ                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2010-04-30 08:59:16 | 
                        By :
                            numenoy | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 การติดต่อ database แบบ connectionless ไม่ต้องเปิดปิด connection ครับ                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2010-04-30 09:03:54 | 
                        By :
                            tungman | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ขอบคุนนะค่ะ แต่ไม่ค่อยเข้าใจเท่าไหร่ ^^                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2010-04-30 09:05:13 | 
                        By :
                            nanamashii | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ถามต่อหน่อยได้ปะคับ เชื่อมต่อ [Sheet1$] กับ [Sheet2$] ยังไงหรอคับ                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2011-04-20 23:56:48 | 
                        By :
                            บิ๊กก้า | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     | 
   
 
                 |