Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1241 Lượt xem

Hi, 

As we do this in odoo's python:

cleared_bal = self.env['funds.flow.tree'].search(['|','|',('cust.id),('date_clearance','

same case if i want to find one id in three different columns of a same table and consider every row which has the target id in any of those three column. How I will write a query?

I have checked the internet but they were not helping, may be they were written in django or plain python. Much appreciate the help.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

In sql:

SELECT * FROM your_model_name

WHERE first_column = target_id

OR second_column = target_id

OR third_column = target_id;


In the database, models (tables) have underscores instead of periods.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

If you're working with Odoo's ORM in Python and you want to search for records where a specific ID is present in any of three different columns, you can achieve this using domain filtering in the search method. Here's how you can write the query:


records = self.env['your.model.name'].search([

    '|', '|',

    ('first_column', '=', target_id),

    ('second_column', '=', target_id),

    ('third_column', '=', target_id)

])


Hope it helps

Ảnh đại diện
Huỷ bỏ
Tác giả

Hi @cybrosys
I want to write a postgree sql Querry for that.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 2 25
1353
2
thg 1 25
7796
2
thg 1 24
10137
0
thg 9 23
6136
7
thg 1 24
48741