like within query - sql

I am using vs 2010 and want to perform a query on sql server database. But i have a problem i want to retrieves a row on the basis of name which i want to retrieves it using second character of name that is i don't know the first character that is for example the name is nik as i enter i it will retrives a record which having nik as value of name column.
Can any one guided me...I know following query what things i have to modified in it.
select * from table1 where name like '"& n % &"'

for example the name is nik as I enter i it will retrives a record which having nik as value of name column
try
select * from table1 where name like '_i%'
TSQL Like

Related

How to get some value from the sql database based on certain criteria

Suppose I have given such a table in sql
According to Gmail (which I have given in advance) I want to get the Username value.
For example, if "Gmail" would be "Gela1#gmail.com" I should get string - "Gela gela".
if "Gmail" would be "mamuka#gmail.com" I should get string - "Mamuka snaia".
How to do this?
You can easily make an SQL query like:
SELECT Username from tableName where Gmail = 'Gela1#gmail.com'
Replace tableName with your table name.
https://www.w3schools.com/sql/sql_select.asp

Show only column name in a HUE hive query

So in Hue I've entered a simple query(has to be as simple as possible, as others will run it too) to just get a limit of 20 records. The query is:
Select * from tablename Limit 20
The problem is that the query returns column names in this format: tablename.columnname
I need JUST the column name to be returned, NOT the table name referenced at all. How is this achieved without going into a large "from" statement spelling out all of the columns(only other way I currently know)?
Thanks in advance!
Not the best but you could do a right click on the '*' of SELECT * and then expand all the column names:

Retrieve data from LIKE Query

I have a database table named 'manufact' which has columns like below.
Whats the SQL command to Retrieve the manufacturer details whose names start with letter A to N.
Select * from manufacturer where manu_name like '[A-N]%';

Extracting a string value from a pipe-separated string in a table column

I'm an Oracle newbie.
I have a column in my table that contains a pipe(|)-separated string such as this:
uguyguyguyguyguy|0737494110|noreply#xxyyxx.se|E:\PROD_ActionMarketer\Program\Apsis\ApsisREST.exe|E:\PROD_ActionMarketer\Temp\TempApsisAdmin.skv|SENDEMAIL|"LIST=Daily SMS SPL"|1015832
As you see the penultimate value begins with "LIST=". I want to extract the value after this string i.e. "Daily SMS SPL" to be able to compare it with another column in another table. I want to obtain this value ("Daily SMS SPL") using a SELECT query if it's possible.
So let's say the table name is MYTABLE and the name of the column is MYCOLUMN.
SELECT SUBSTR(surname,1
,INSTR(surname,'"',1,1)-1) FROM
(SELECT SUBSTR(column
,INSTR(column,'LIST',-1)+5
) AS surname
FROM table)
FIDDLE

Get alias name dynamically in Postgresql

I have one table named tblalias.which is having two columns cid, description
cid description
1 Employee
2 Join Date
3 Retire Date
Like this three record is present
Now I have another table tblemployee. I want to write a query for tblemployee to get record but alias name for that query I want should come from tblalias
select nama as Employee,
joindate as "Join Date",
retiredate as "Retire Date"
from tblemployee
If I change value is tblalias table to my select query should return new value as alias is it possible if yes how please help me
The only way to do this is with dynamic SQL. First fetch the alias names then build the final SQL and execute it.
There is no way doing this with a single "hardcoded" statement.
If you want spaces in names you should quote them. (spaces in names is generally a bad Idea, but that's another matter)