Search for all strings that have a space in between using 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
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 '% %';

Related

finding the word like in a 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
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.

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,}$'

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

SQL Query - Set column1 with values from column2 based on the value of column3 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to update column1 with values from column2 based the value of column3. This is what I have:
UPDATE Table
SET Column1=Column2
WHERE Column3='Value'
Is this possible?
EDIT I tried this, but I didn't get the results I wanted (as in, none of my rows changed). I didn't get any errors though.
UPDATE Figured out my error. Answer is below.
Ah, Okay. Now I see where I went wrong. The Value of Column3 has the same name as Column2, so I messed up the order. This is what worked:
UPDATE Table SET Column2=Column1 WHERE Column3='Value'

Create an ORACLE data dictionary of tables with more than 2 indexes [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm having trouble trying to figure out in an ORACLE data dictionary whether a table has more than 2 indexes.
You can start by looking at a dictionary table such as ALL_INDEXES and trying something like this:
SELECT TABLE_NAME
FROM USER_INDEXES
GROUP BY TABLE_NAME
HAVING COUNT(*) > 2;
I haven't tried the code, or read the doc in detail to see if there may be cases where things show up twice, but it should put you on the track.