Skip to content
Advertisement

How can I append a string to an existing field in MySQL?

I want to update the code on all my record to what they currently are plus _standard any ideas? So for example if the codes are apple_1 and apple_2 I need them to be apple_1_standard and apple_2_standard Before: Psuedo Query: Expected result: Answer You need to use the CONCAT() function in MySQL for string concatenation:

Mysql Complex Where Clause

I really surprised when I tried below code in MySQL: It doesn’t work. I need to get product that is both free_shipping is ‘yes’ AND price equal ‘5’ at the same time. How can I create this query properly? Table Structure: contents: (TABLE 1) content_fields: (TABLE 2) Example (Get product that has 1 ID and its shipping is FREE): Answer

SQL/C# – Best method for executing a query

I need to execute a sql query from within a c# class. I have thought of 2 options Starting a process of sqlcmd. Using a SqlCommand object. My question is which would be the better way? It’s important that the solution only holds a connection to the server for a short time. I’m open to other ideas if the above

Get the 2 digit year in T-SQL

I need to get the current 2 digit year and increment by one. So the current number I’m looking for should be 11. Probably really simple but I’m a sql noob 🙂 Thanks Answer You can do ( YEAR( GETDATE() ) % 100 ) + 1 See GETDATE & YEAR

Variable value assignment using RETURNING clause

I try to do this, but it’s a syntax error, what am I doing wrong? my table: Answer You need to use the INTO clause in the RETURNING to set the value being returned into your variable: You also need to specify the data type of your variable; I’m glad to see postgresql supports %TYPE and %ROWTYPE.

SQL query for non duplicate records

I’m attempting to build a query that will return all non duplicate (unique) records in a table. The query will need to use multiple fields to determine if the records are duplicate. For example, if a table has the following fields; PKID, ClientID, Name, AcctNo, OrderDate, Charge, I’d like to use the AcctNo, OrderDate and Charge fields to find unique

mysql CREATE VIEW not working from mysql_query

I have a code to create VIEW in mysql database which is working fine on my local server. It creates and crop view normally. But on my Online server it gives error for online database I manually create VIEW in Database form PHPmyAdmin [Myadmin is in localhost online] it creating, SO i have permission to create VIEW on online database.

How to count one to many relationships

ReporterTbl has a one to many relationship with AttachmentTbl. In ReporterTbl, I have an ID (101) and I can have AttachmentTbl more than one Attachments related with ReporterTbl.Id Basically, what I am trying to know is given ReporterTbl.ID, how many Attachments do I have? Table structure: Answer Note: It is important that we are using count(a.id), and not count(*). This

Advertisement