473,396 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

problem in searching data from sql

I want to search data from a table where i want to seach according to five fields
the problem is that user can fill any field in any one of them and make other fileds blank,Then seach will done according the fiels supplied for seach.
Mar 28 '07 #1
3 1286
iburyak
1,017 Expert 512MB
This is select statement I wrote for someone else.

Hope it helps

[PHP]select *
from TestTable
where column1 like case when isnull(@Variable1,'') = '' then '%' else @Variable1 end
and column2 like case when isnull(@Variable2,'') = '' then '%' else @Variable2 end
and ..... [/PHP]

You can go here to view discussion

http://www.thescripts.com/forum/thread623381.html
Mar 28 '07 #2
Hi

Try this:

Expand|Select|Wrap|Line Numbers
  1. SELECT ColumnList FROM YourTable
  2. WHERE COALESCE(Field1, Field2, Field3, Field4, Field5) = 'Search Criteria'
  3.  
Mar 29 '07 #3
iburyak
1,017 Expert 512MB
Hi

Try this:

Expand|Select|Wrap|Line Numbers
  1. SELECT ColumnList FROM YourTable
  2. WHERE COALESCE(Field1, Field2, Field3, Field4, Field5) = 'Search Criteria'
  3.  

I don't think that COALESCE is correct approach.
Coalesce is searching for first not null field nothing to do with searching a value.
Mar 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

38
by: jrlen balane | last post by:
basically what the code does is transmit data to a hardware and then receive data that the hardware will transmit. import serial import string import time from struct import * ser =...
3
by: Alex Ayzin | last post by:
Hi, I have a problem that might be easy to solve(possibly, I've just overlooked an easy solution). Here we go: I have a dataset with 2 datatables in it. Now, I need to do the following: if...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
1
by: hash | last post by:
Hello! While trying to port VC6 code to VC8, I stuck at this DLL problem. While compiling my project which is DLL, I am getting this error mfcs80d.lib(dllmodul.obj) : error LNK2005:...
0
by: Muhammad Shoaib | last post by:
Hello Everybody! I'm using vb.net 2005 and MSSQL Server 2000 as back end i have little problem while i want to show only the data which i want, it gievs me problem infact i want to place a select...
11
by: TheDataGuy | last post by:
Using MS ACCESS 2002 I developed a FORM, and within that FORM, I created and added a SEARCH BUTTON, and then I created a SUB-FORM, so that when an the END USER clicks on the FORM it will POP-UP...
0
by: jyotsnamk | last post by:
Hi, I am facing a problem using bsearch . Even though the data Im searching for is present in the array, the function returns a NULL object. The array is a structure with the following...
1
by: arnold | last post by:
Hi all, I have created a form which gives the user the ability to search for specific data. Number of records in my database exceed one million records therefore in some occasion...
10
by: jonathan184 | last post by:
Hi I tried getting this to work through dreamweaver but it did not. So i found a n example on the internet , i followed everything exactly the search script does not work. Could somebody help me...
2
by: preeti13 | last post by:
hi friends please help me with my problem i have a code for search application it is searching one record from the data base at a time but i have so many records with that name but its not searching...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.