I need to write a sql statement(Oracle) where I can withdraw data from two diff tables and check for a condition and return a certain string. My statement goes like this, When I run this I get a error: “FROM keyword not found where expected”and points to the c in line 2. and if I change the from t…
Tag: sql
I need to optimize tables and queries
I have 3 tables: info, data, link, there is a request for data: offer optimization options: a) tables b) request. Queries for creating tables: Thanks! Answer Never use commas in the FROM clause. Always use proper, explicit, standard, readable JOIN syntax: Second, for this query your indexes are probably fine.…
MS SQL Find a Value in entire column and return true if found
New to SQL trying to find how to do the following : I have a ProductID# ABC123 (Product) I need to check the “workflow” (Workflow) column and see if the Product ID was ever “extended” – there are various workflow steps – Need to check the entire workflow column, if a Produc…
Grant Select To Synonym For Specified Columns
I’ve been trying to restrict a user’s select access to a synonym. Consider the following below: I get an error: Msg 1020, Level 16, State 3, Line 4 Sub-entity lists (such as column or security expressions) cannot be specified for entity-level permissions. But if I change it to use dbo.Items direct…
Correspondence between two tables
I have table the table code_Commune contains gps for the city in general code_Commune: Now I need to do correspondence with the table lead to add code_commune and Nom_Commune: Table lead Is there any way to do correspondence between the two tables? Answer You can find the closest city using some sort of dista…
String concatenation in SQLITE with NA values?
Currently working in SQLite and have the following table I would like to create a new column – which is the concatenation of the columns subject_1 and subject_2, however I have values within my subject_2 column – is there a way of concatenating the columns so that I can get the following table Now…
how to show the selected value from database in select box in codeigniter
Here I have a select box where I want to show the value which is stored in the database that is in the JSON format. If the value is present, it shows the selected value, otherwise it shows the default option Delete leads option. It’s not working properly. Can anyone please help me? Answer I think you co…
How do i use COUNT with JOIN SQL 3 tables
I have 3 tables. First table is Battles with columns: –battleId(primary)–gameId(foreign)–prize– Second table is Games with columns: –gameId(primary)–gameName– Thrid table is …
How can I get the 10 most recent rows from a database?
I want to choose an id in a table, sort it by date and show only the 10 newest entries. I have already tried following command: SELECT * FROM weather WHERE DATUM = (SELECT MAX(DATUM) WHERE ID=’0′)
Selecting 7th Person (row) and get 7 as result
I want to select the 7th person (Pierre Gasly (for example)) Score list Season F1, so I can return number 7 in my C# application. SELECT CONCAT(strVoorNaam, strTussenVoegsel, ‘ ‘, strAchterNaam) AS …