Skip to content
Advertisement

Tag: string

Multiple strings in one SQL field

I am trying to revamp an order system for an e-commerce web site. The header table for the orders is tbl_orders, that’s working fine but there is another table underneath that (so to speak) called tbl_orderitems In this table tbl_orderitems I store an Id that refers to the items image but sometimes there is more than one image associated with

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:

Can MySQL replace multiple characters?

I’m trying to replace a bunch of characters in a MySQL field. I know the REPLACE function but that only replaces one string at a time. I can’t see any appropriate functions in the manual. Can I replace or delete multiple strings at once? For example I need to replace spaces with dashes and remove other punctuation. Answer You can

How to use GROUP BY to concatenate strings in MySQL?

Basically the question is how to get from this: foo_id foo_name 1 A 1 B 2 C to this: foo_id foo_name 1 A B 2 C Answer https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat From the link above, GROUP_CONCAT: This function returns a string result with the concatenated non-NULL values from a group. It returns NULL if there are no non-NULL values.

Advertisement