Note that the answers to many database related questions can be found in our FAQ's & Tutorials, so you may well find your answer there.
If your issue is not there, you will need to create a thread.. and you will get much quicker (and more accurate) answers if you follow the guide below.
The following items can make serious differences to what will work for you, even if you don't think they are relevant:
- Please always specify the Database system, and preferably the Version too (eg: MS Access 2003, SQL Server 2000, SQL Server 2005 Express, MSDE 2000, MySQL 4.1, Oracle 9, etc)
Note that SQL is not a database system, it is a language used to get/manipulate data from various databases - including all of those mentioned above.
- If you are working from a program (rather than in pure SQL), please specify if you can:
Language used (such as VB6, VB.Net 2003, Access VBA)
Connection method (such as ADODB, DAO, ADO Data Control, DataSet)
Provider (OLEDB or ODBC) or Connection String
- If a piece of SQL or code you have isn't working, please show it to us. It is much easier to correct something than re-create it (it may also help clarify your actual question). Note that if you are building an SQL statement via code, please also show us the final statement that is being run (here's how).
- If you are getting an error, please tell us exactly what it is (the message, and preferably the number too), and where it is occurring (if you are posting several lines of code, let us know which one).
- If you are having problems getting an awkward SELECT statement working, please give a few example records of the data in your table(s) and an example of the data which you want to get back.
NB: It is also useful if you can show us the metadata (ie: the table name, and list of fields with their data types).
If speed is an issue, you should also let us know an estimate of how many records will be in each table.
An example question:
I am using ADODB code to connect to a SQL Server 2000 database from my VB6 program.
No data is being returned when I use Like, even though I know there is matching data in the table; no error is occurring.
It works fine without the Like part, but returns all the records in the table!
Here's my code:
Why wont it work?VB Code:
- rs.Open "SELECT * FROM my_table WHERE field1 Like '*test*'", cn, adOpenKeyset, adLockOptimistic, adCmdText
After you've gotten the answer to your question, please help us by marking your thread as resolved (so that we don't waste time trying to work out solutions for things that are already fixed!). To do this, click on Thread Tools just above the first post of the thread, and click on "Mark Thread Resolved". This will add a tick icon () and the word [Resolved] to the thread title.