Value to select of field

Hi,

 I've got a question!

In a database I have a field interest-target with values like 8,15,115,3 and 18,13,15,6 and 51,6,7,118 etc.

Now I like to select from these fields the value 8. I tried the following:

SELECT * FROM TABLE WHERE FIELD LIKE '%8,%' OR FIELD LIKE '%,8,%' OR FIELD LIKE '%,8%'

I will the also get the value 18 wich I don't like :-(

Any solutions here?

Thanks!

 Roel


Roel Alblas, Dordrecht, Holland,
www.gps2sms.nl
0
RoelAlblas
2/27/2008 6:26:24 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

7 Replies
500 Views

Similar Articles

[PageSpeed] 7

Although it's REALLY ugly, you could try:

AND FIELD NOT LIKE '%18%'AND FIELD NOT LIKE '%28%'AND FIELD NOT LIKE '%38%'AND FIELD NOT LIKE '%48%'AND FIELD NOT LIKE '%58%'AND FIELD NOT LIKE '%68%'AND FIELD NOT LIKE '%78%'AND FIELD NOT LIKE '%88%'AND FIELD NOT LIKE '%98%'AND FIELD NOT LIKE '%81%'AND FIELD NOT LIKE '%82%'AND FIELD NOT LIKE '%83%'AND FIELD NOT LIKE '%84%'AND FIELD NOT LIKE '%85%'AND FIELD NOT LIKE '%86%'AND FIELD NOT LIKE '%87%'

AND FIELD NOT LIKE '%89%'

 


- Corwin
(My Blog - www.ballhead.com/corwin)
0
Corwin
2/27/2008 7:18:30 PM

If you just need the one's that have an '8', then you should just have the following:

SELECT * FROM TABLE WHERE FIELD LIKE '8,%' OR FIELD LIKE '%,8,%' OR FIELD LIKE '%,8''

and not the others....


Click on 'Mark as Answer' if this post is helpful.

-- Randy
0
ratkinso
2/27/2008 7:26:32 PM

:-D

 That is a solution! Thanks!

But ... I've got an XML filling the database with a million nodes :-(

Any suggestion except try XQuery?

Thanks in advance!

Roel


Roel Alblas, Dordrecht, Holland,
www.gps2sms.nl
0
RoelAlblas
2/27/2008 7:31:56 PM

It shouldn't matter if there are a million of them...  not sure what you mean...


Click on 'Mark as Answer' if this post is helpful.

-- Randy
0
ratkinso
2/27/2008 7:34:28 PM

Hi,

I meant: it's not only the 8. I also like to select 4 within 41, 14, 45 etc and these combinations are a lot.

Thanks!

Roel


Roel Alblas, Dordrecht, Holland,
www.gps2sms.nl
0
RoelAlblas
2/27/2008 7:59:06 PM

Sorry, I guess I am not getting something, but if you need the 4's then it would be just like the 8's but with 4's...

SELECT * FROM TABLE WHERE FIELD LIKE '4,%' OR FIELD LIKE '%,4,%' OR FIELD LIKE '%,4''

 

Your original question said you wanted the 8's, but not like 18 and your query was of course returning 18, but the one I posted should not return the 18 one's, are you saying that it is??

 

Randy


Click on 'Mark as Answer' if this post is helpful.

-- Randy
0
ratkinso
2/27/2008 8:05:33 PM

Sorry Randy, I think it is my english!

My problem is solved!

Roel


Roel Alblas, Dordrecht, Holland,
www.gps2sms.nl
0
RoelAlblas
2/27/2008 8:19:20 PM
Reply:

Similar Artilces:

Selecting value in one field then causes value in another field to be selected.
I have a web form which contains a date field, the date is populated using a DatePicker which is Javascript based. The form also has a drop down box containing 3 values. What I want to do is when a date has been selected that this will cause the dropdown list value to change to dated which is one of its 3 values. i.e. when the date field is not blank then the value will be selected in the dropdown. What I also want to happen is when the date has been selected and the dropdown value is dated then the date field and the dropdown field will be set to read only.Anyone any ideas how to this usin...

linking a sql field to point to the value of another sql field
is it possible to create hyperlinks in powerbuilder such that if you retrieve two fields from a database.. and want to display the first field on the screen and have it link to the value of the other field (when clicked) which is actually a URL address, you can? any help will be appreciated. thank you! ...

problem with selected text field and selected value field in check box list
Hi! i have a  problem with check box list:here is the code for binding the check box list with sqldatasource  SqlDataSource1.SelectCommand = "select vcentrolno,inttpaperno from tabmarksdetails where vcbunchno='" & strBunchNo & "'"  chkEnrolNos.DataBind()say now my chkEnrolNos consist of data in this way:vcentrolno        inttpaperno selected text   selected valueA11439            1A11439            2AR439    ...

SQL insert with select and specify value for a field
Hi, Can someone tell me if it is possible to do an SQL insert with a select (to copy specific records) query and specify the value for a specific field to insert in the new records instead of using the value in the field in the select statement. If so can you provide me with a simple example.  Cheers Mark :) Please descript what you want to accomplish."Object reference not set to an instance of an object" Hi,  Don't worry I figured it out.  If I use a stored procedure I can just create a varaible e.g strFileId int and then do this ...

select cheboxlist if any values are selected in sql
hello and thanks in advance,  I have a checkboxlist that is created dynamically from table1 once the records are inserted they are inserted in table2. i can save the values into the table and remove them if i uncheckd them that is working fine. the problem is to checked the items that have been selected already, how to i do this?? really really confuse...   here is the cs code; namespace IMS_2K9.Admin { public partial class Order_Charges : System.Web.UI.Page {private string connectionString = WebConfigurationManager.ConnectionStrings["IMSCon...

Adding a default value to sql select parameters in vb.net
Hi,     I know it's easy to select the default value if you use the sql data source object to configure your query and feed it the select parameters. However, i will like to know if it's possible or what's is the syntax to add a default value to sql query being executed before page is post back. Below is what i have so far: the text strikethrought is the missing piece i need help making it the default value.Dim connect As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Solution_DA_LiveConnectionString").ToString()) Dim sqlcom...

Select three fields in SQL datasource but only display two in datalist
How would I do this?  I have to select the First and last name to show up in the datalist, but I also need to select the key because I am updating another column in the selected row.  How would I display only the first and last name? You can edit the html in the aspx page and remove that item from the templates.BrucePlease remember to click "Mark as Answer" on the posts that helped solve your issue. The problem is the template doesnt know the name yet because the sql select is selecting from a "' + table + '" so that wouldnt work.  Sorry I forgo...

Selecting values in DDLs with values from SQL DB
On my page I have four drop-down lists: startWeek, startYear, endWeek and endYear which sets a period of time.The default values, that must be displayed on page load, are selected from a table called Period in a SQL database using a Linq.DataContext class called MyContextClass. The periods (a period is a week in a given year) in this table can be active/inactive. In the code I select two active periods: The one with the lowest ID (the earliest period) and the one with the highest ID (the latest period). I then try to display these two periods in the four drop downs: the first two lists conta...

Accessing SQL datasource selected values in code behind when they're pulled from formview, listview, datagrid, etc..
Hello, In my usage of asp.net 2.0 so far I've been having a consistent lack of technique at one particular concept: In my code behind with vb, getting at the values pulled by my sql datasource that are used in my formviews, listviews, etc... What are some of the general techniques to accomplish this? What are the easiest ways? If I try to assign output parameters in my query I get errors because sql doesn't want them being used for the data consuming controls as well as assigning parameters. Lately I've been making the textboxes that are populated by the f...

Using selected values from a Multi Select Listbox in a SQL query
I have seen a few post concerning this but don't really understand fully as I am new to this.  I would appreciate any help 1) First I loop through the Listbox control and get the selected values: Dim li As ListItemFor Each li In lbPClass.Items If li.Selected = True Then strPC += li.Value & ", " End If Next Label5.Text = strPC The resulting string looks something like: 101, 102, 100 ,    I get rid of the last space and "," with the following statement Label6.Text = Left(Label5.Text, Trim(Len(Label5.Text) - 2)) 2) I would then like to ...

Drop down list in Form view returns error when value in bound field (data binding
I get the following error when I click edit to edit the details in the web form:'ddlUserRestrictionType' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value  I would like it to accept any value which currently exists in the database. Is this easily achievable? With what you've posted, all I can tell is that you are trying to set the SelectedValue of a ddl to a value that does not exist in the list.  It would be helpful if you can post some code and the expected values of this control.~ Timwww.bucketo...

Dropdownlist selected value passes first value in list no matter what value is selected. why ?
 HI . I have a dropdownlist. Databinds ok but when I must pass a value as a Selected value it always passes the first value in the list even if I select another value. I tried to set the ddl to enableviewstate false but it doesn't change anything. Any ideas ? Code below, thanksLoading the ddl:       productCategories = CatalogAdmin.Admin_Product_Categories_NotIn(productId);        for (int i = 0; i < productCategories.Rows.Count; i++)        {       &...

Updating non-nullable field in SQL with default value through dynamic field
Hi, I'm running Server 2008 and the 3.5 sp 1 Dynamic Data. I've got a Dynamic Data application using Entity Framework for its model, and I have a non-nullable datetime field that I don't want to scaffold; I want the database's default value to go in every time. In my partial class in the entity project, I've decorated the field with [Scaffold(false)], and I've also set the field setter to be private. The field does not render out to the page (good), but it still expects a value and breaks when I try to submit the rest of my fields exposed in a DetailsView control. I...

Select value from drop down then other fields shows value in textfield depends on the dropdown.
 Hi,em new in VB.NET & develop a web based transaction which is almost 50% complete.my problem is that i have a form of Item properties, which consist on a following fields,1. Item2. Unit3. Old Price4. New Price my client wants that if user select Item from the dropdown then other fields shows value automaticlly on the textfields which is depend on the item name.for example:if user select Colgate from the dropdown then Unit, Old Price and New Price shows in textfeilds seperately.  if u have any code and tutorial about the above example then kindly share with me i will...

How to select a field value from a selected row from a DataGrid in order to use it as a parameter
I am working on a web application, and I have two DataGrids.  Then end-User is supposed to select a row from one of the grids, and the event should select a key from that row in order to use it as a parameter to fill the other DataGrid.  I have been trying to do so, but I dont work the same way as I used to do it in windows applications.   I would appreciate any suggestions,   Thanks. Is there some code we can look at? I've done similar things and I've never had any problem with them. In the first grid have a select column, when it is clicked you can catch the Sel...

Web resources about - Value to select of field - asp.net.sql-datasource

United States House Select Committee on Energy Independence and Global Warming - Wikipedia, the free ...
but will work with the House standing committees with jurisdiction over climate change issues and develop recommendations on legislative proposals. ...

kotaku selects
Kotaku Selects

Facebook Testing ‘Select Ad Variations To Generate’ Option In Power Editor?
Facebook appears to be testing a new feature in Power Editor that allows users to more easily test different versions of their ads. continued… ...

Hyundai set to bring CarPlay to select cars early next year after delay
... update to be released during the first quarter of 2016 that will enable the CarPlay feature on supported models with a connected iPhone. Select ...

Apple Selects Best Apps, Games of 2015
Apple revealed its “Best of 2015,” highlighting the best applications and games the iTunes App Store had to offer this year. Apple selected ...

Google Play offering select buy one, gift one movies for the holidays
... a few days ago, Google is giving you the chance to purchase a movie and gift that same movie to a friend for no extra charge. The selection ...

US confidential note to select countries sets the terms for talks
... between developed and developing countries scrapped Days ahead of the launch of the Paris talks, the US has confidentially informed select countries ...

Cisco Selects Netformx Discovery to Power New Net Authenticate Assessment Service
Cisco Selects Netformx Discovery to Power New Net Authenticate Assessment Service Business Wire (press release) SAN JOSE, Calif.(BUSINESS WIRE)Netformx®, ...

Abbott selects DISD trustee Mike Morath as Texas’ new education commissioner
Updated at 8:08 p.m. AUSTIN — Gov. Greg Abbott on Monday appointed Dallas Independent School District Trustee Mike Morath, an admittedly nerdy ...

Cortana Exits Beta, Available for Select Android and Cyanogen OS Powered Devices
... , the digital assistant made to be the perfect companion for Windows users, has officially exited beta, made available to a number of select ...

Resources last updated: 1/2/2016 7:44:01 PM