finding the word like in a sql query [closed] - sql

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a string like this:
i would like to go to office, and i would like to go to market
My question is: how many times the word like occurs in the string?
Please write a query.

You can use regexp_count:
SELECT REGEXP_COUNT('i like to go , and i would like market', 'like')
FROM DUAL;

The word "like" occurs twice in the string you posted.
The following is a query:
SELECT *
FROM SOME_TABLE
WHERE SOME_VALUE = SOME_OTHER_VALUE
Share and enjoy.

Related

SQL LIKE doesn't find obvious matches [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I'm writing the following SQL query:
SELECT *
FROM OS
WHERE OS.VERSION LIKE '%1%';
In my table there are rows with char 1 in it. However, it returns an empty result.
I changed a little bit the LIKE clause to different values, but it still doesn't work.
What can I do to fix that?
Try double-quotes and * for wildcards. You are using Oracle syntax instead of Access syntax.
LIKE operation can't be used with columns of integer type. I assume that OS.Version is of integer type?
Edit1:
If you are referring to MS Access then you have to do the LIKE with stars (*) instead of %.

Access 2010 SQL Update Query [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I need to update every row in one table, with the help with two subqueries...
UPDATE MyTable
SET MyTable.ColumnToUpdate =
((SELECT 10000 / DCount("ID","MyTable")) * DCount("ID","MyTable","ID<="& MyTable.ID))
But this doesn't work, access complanis about an error in the first subquery...
How can i do this?
Thanks
You don't need the SELECT statement in the first piece. Try this:
UPDATE MyTable
SET MyTable.ColumnToUpdate =
((10000 / DCount("ID","MyTable")) * DCount("ID","MyTable","ID<="& MyTable.ID))

How to be a command in SQL using LIKE? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to select records where a field (varchar (45)) contains one and only one letter x and the field length is greater than 20
In MySQL you can do:
SELECT * FROM tablename WHERE fieldname REGEXP '^[x]{20,}$'

Search for all strings that have a space in between using SQL query [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Take for example I have entries like 'Jhon Abraham','Hrithik Roshan' and 'Jimmy'.
Then, the output should fetch me the first two entries i.e. 'Jhon Abraham' and 'Hrithik Roshan'.
SELECT columnName
FROM table
WHERE trim(columnName) LIKE '% %'
SELECT col_name FROM table_name WHERE col_name LIKE '% %';

Counting lines in a list [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I have a list of objects and colors; each object has a color. I want to create a query that will count how many objects I have of each color.
What function should I use?
You might write a query like this:
SELECT COUNT(color) AS cnt, color FROM YourTable
GROUP BY color
SELECT Color, Count(Objects)
FROM myTable
GROUP BY Color