The List function in Firebird 2.1. This is an aggregate function that returns a string with the field values concatenated using a delimiter. the default delimiter is the comma. So it's similar to the SUM function, but instead of adding numbers, this function concatenate strings. if some of the values is null then the function returns null. So suppose I have 2 tables, projects and resources, and I know that a project will have a few resources assigned. Now I need to write a report of projects showing their resources assigned. CREATE TABLE projects( project_id INTEGER, name string ); CREATE TABLE resources( project_id integer, user_name string ); Without the LIST function I have to write this query SELECT p.project_id as id, p.name, r.user_name FROM projects p INNER JOIN resources r ON p.project_id = r.project_id my result will be like this id name user_name ------------------------- 1 Project_1 Steve 1 Project_1 John 2 Project_2 Ji
A veces cuando alguien quiere hacerme una pregunta, empieza por darme contexto sobre el tema del que va a preguntar. Me empiezan a explicar cómo fue que llegaron a la pregunta que tienen en mente. Algunos comienzan por explicarme lo que han intentado para resolver el problema que enfrentan, me explican el porqué de esos intentos. Ha habido, incluso, ocaciones en que me explican las respuestas que han encontrado en internet; pero todo esto sin haberme hecho la pregunta todavía. Comprendo que me dan el contexto para ayudarme a encontrar la mejor respuesta, también lo hacen para que no crea que no han intentado encontrar la respuesta por su cuenta; o quizás para que no piense que me consultan sin tener una buena razón. Entonces empiezan por justificar el porqué de la pregunta sin siquiera haberme hecho la pregunta todavía. El contexto de la pregunta es importante, sirve para saber de qué estamos hablando en realidad, lo cual es bueno para dar una respuesta correcta. Entender el porqué si
Another great feature that I like in Firebird 2.1 is the UPDATE OR INSERT statement. It's a really time saver and it makes the SQL cleaner. For example suppose I have a products table like the one I use in my last post and an inventory table to store the product stock. Before Firebird 2.1 if I want to set the stock for a product I needed to check if a record for that product_id already exists; if the product_id already exists then I write an update. If not then I write an insert statement. So I ended up with something like this: IF EXISTS(SELECT * FROM inventory WHERE product_id = :product_id ) THEN UPDATE inventory SET stock = :stock WHERE product_id = :product_id; ELSE INSERT INTO inventory (product_id, stock) VALUES (:product_id, :stock); In this example I only update one field but when I have to update a big table I ended up with a big chunk of code and thinking: "there should be another (better) way to do this". Fortunately now with
esta bonita nina tan bonita pero latosa jijiji de verdad
ResponderBorrarMuchas felicitaciones Mario, los mejores deseos para ti y toda tu familia.
ResponderBorrarGracias
ResponderBorraresa soy yo :) estaba tan pequeña. :3
ResponderBorrar