Skip to content
Advertisement

Tag: function

Simulating SELECT YEAR(post_date) SQL query using only WP Query

I’m not entirely sure this is possible but I’m completely out of ideas. The task I’m working on requires that I specifically use WP_Query due to constraints of other efficiency plugins my organization uses. Pure and simple, I need a way to simulate the following query using WP_Query: “SELECT YEAR(post_date) FROM wp_posts WHERE post_status = ‘publish’ GROUP BY YEAR(post_date) DESC”

Cant understand my syntax mistake in MySQL CREATE FUNCTION

This is my code and I can not find the mistake! I am trying to create a function that multiplies a value to de input parameter and returns that result! It should not be that difficult but I am not finding my sintaxt mistake The mistake says: error code 1064 Answer The DECLARE has to be before the code. I

How to make mysql function that return from the select result?

I want to create this function on mySql 8. It will create a sequence number like 00001,00002 i dunno whats wrong with this query but i always got this error. I also tried with this query. but still gave me with the same error. What could go wrong with my function query ? Answer Multiple datatype convertions are excess –

SQL Function has no destination when called

I’m getting a success when creating the below function, but when I call it I receive an error stating there is no destination. Answer Language SQL: https://www.postgresql.org/docs/current/xfunc-sql.html language plpgsql: https://www.postgresql.org/docs/current/plpgsql.html Language sql is more easier to understand. your query is not dynamic, so it’s just a function and $$ query $$. setof inventory.filmid%type will make it more flexiable. If you

While loop function union function end

I want to loop the code shown below. I would like to use the [getpublicholidays] function for a variable number of years and merge them (union). Unfortunately I don’t know how to use the function in a loop with union. Can someone help? Answer If you are looping for X years, each time you loop to a new year, you

User function return query and insert into

I trying to make function, that merge where select query return result as value(not table) and insert into that use value from select statement. The function where argument gets from user, and this argument provide into select query on table_foo that return value id where I try set and use in insert into to diff table(table_bar). So I little bit

Advertisement