Direkt zum Hauptbereich

Select the rows depending upon the occurence



SELECT `id`
FROM table
GROUP BY id
HAVING COUNT(*) = 1



id  column1 column2
--------------------------
1    value1 value2
1   value1 value2
2 value1 value2



Executing the above query will get a result

id
---
2


while occurence of the id = 2 is only once

Kommentare

Beliebte Posts aus diesem Blog

How to - Web browser Control

 Creating a simple HTML Editor using Web brower control Create a basic Winform Appln. Drag a Webbrowser( end in the list ) from Toolbox. To  create buttons drag a Toolstrip control (near webbrowser ctrl in the list 'Commoncontrols' ) from Toolbox. You can add buttons, text box, progressbar etc by clicking. c   To make the Web browser control editable you have to write the following code while initializing.   InitializeComponent();    webBrowser1.DocumentText = "<HTML><BODY contentEditable='true'></BODY></HTML>";                      toolStripComboFontSize.SelectedIndex = 2; Double click on buttons to generate events. Variable possibilities are there . Some are given below, 1. Change text color  if (colorDialog1.ShowDialog() == DialogResult.OK)           ...

Stored Procedure Returns GUID

This stored procedure returns GUID (GUIDColname) as output. Use databasename; Go CREATE PROCEDURE dbo.procname @Col1image, @Col2 varchar(50), @Col3varchar(5) AS     INSERT INTO dbo.tblname (Col1, Col2, Col3)     OUTPUT inserted.GUIDColname     values (@Col1,@Col2,@Col3) GO & the query looks like INSERT INTO dbo.tblname (Col1, Col2, Col3)     OUTPUT inserted.GUIDColname     values (null,null,null)

Binding Checked List Key, Value pairs !!!

I have been wonderinghow to do this , microsoft ist currently not encouraging people to use DataSource property. Evenif its existing its not enabled.  #############################################################  BindingSource bs = new BindingSource();  Dictionary<int, String> dicKeyValue = new Dictionary<int, String>(); // Add key, values to the dictionary   while (Reader.Read())             {                           dicKeyValue.Add(Convert.ToInt32(Reader["id"]), Convert.ToInt32(Reader["name"]));                             } // Set the datasource of BindingSource   bs.DataSource = dicKeyValue;  cListBox.DataSource = bs...